import { isOptionalOf } from "https://deno.land/x/unknownutil@v3.12.1/mod.ts";
Return a type predicate function that returns true
if the type of x
is T
or undefined
.
import { is } from "https://deno.land/x/unknownutil@v3.12.1/mod.ts";
const a: unknown = "a";
if (is.OptionalOf(is.String)(a)) {
// a is narrowed to string | undefined
const _: string | undefined = a;
}