import { isOptionalOf } from "https://deno.land/x/unknownutil@v3.9.0/is.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;
}