import { isUnwrapReadonlyOf } from "https://deno.land/x/unknownutil@v3.18.1/is.ts";
Return an Readonly
un-annotated type predicate function that returns true
if the type of x
is T
.
This is unstable and may be removed in the future.
To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost.
import { is } from "@core/unknownutil";
const isMyType = is.UnwrapReadonlyOf(is.ReadonlyOf(is.TupleOf([is.String, is.Number])));
const a: unknown = ["a", 1];
if (isMyType(a)) {
// a is narrowed to [string, number]
const _: [string, number] = a;
}
Type Parameters
P extends Predicate<unknown>
Parameters
pred: P