Skip to main content
Module

x/silicon/deps.ts>isOptionalOf

Deno module to generate images from source code using Aloxaf/silicon.
Latest
function isOptionalOf
import { isOptionalOf } from "https://deno.land/x/silicon@v1.0.0/deps.ts";

Return a type predicate function that returns true if the type of x is T or undefined.

import is from "./is.ts";

const a: unknown = "a";
if (is.OptionalOf(is.String)(a)) {
 // a is narrowed to string | undefined
 const _: string | undefined = a;
}