Skip to main content
Module

x/unknownutil/is.ts>PredicateType

🦕 A lightweight utility pack for handling unknown type
Go to Latest
type alias PredicateType
import { type PredicateType } from "https://deno.land/x/unknownutil@v3.18.0/is.ts";

A type predicated by Predicate.

import { is, type PredicateType } from "@core/unknownutil";

const isPerson = is.ObjectOf({
  name: is.String,
  age: is.Number,
  address: is.OptionalOf(is.String),
});

type Person = PredicateType<typeof isPerson>;
// Above is equivalent to the following type
// type Person = {
//   name: string;
//   age: number;
//   address: string | undefined;
// };
definition: P extends Predicate<infer T> ? T : never