Skip to main content
Module

x/unknownutil/mod.ts>isAllOf

🦕 A lightweight utility pack for handling unknown type
Go to Latest
function isAllOf
import { isAllOf } from "https://deno.land/x/unknownutil@v3.9.0/mod.ts";

Return a type predicate function that returns true if the type of x is AllOf<T>.

import is from "./is.ts";

const preds = [is.ObjectOf({ a: is.Number }), is.ObjectOf({ b: is.String })];
const a: unknown = { a: 0, b: "a" };
if (is.AllOf(preds)(a)) {
 // a is narrowed to { a: number; b: string }
 const _: { a: number; b: string } = a;
}

Type Parameters

T extends readonly Predicate<unknown>[]