The is function allows you to verify that a given input matches a given schema.
is
import { is } from "typerun";import { number } from "typerun/schema";const data: unknown = 3;if (is(number)(data)) { console.log(data * 3);} Copy
import { is } from "typerun";import { number } from "typerun/schema";const data: unknown = 3;if (is(number)(data)) { console.log(data * 3);}
The schema to test.
A function returning a boolean that indicates whether the input matches the schema. The function is a type predicate, meaning that after testing the return value, TypeScript will now that the unknown input is of the tested type.
The
is
function allows you to verify that a given input matches a given schema.Example