Files
typebox/docs/types/typeguard.md

786 B

Home | Installation | Usage | Types | Values | Syntax | TypeRegistry | TypeCheck

TypeGuard

TypeBox can check its own types with the TypeGuard module. This module is written for type introspection and provides structural tests for every built-in TypeBox type. Functions of this module return is guards which can be used with control flow assertions to obtain schema inference for unknown values. The following guards that the value T is TString.

import { TypeGuard, Kind } from "@alkdev/typebox";

const T = { [Kind]: "String", type: "string" };

if (TypeGuard.IsString(T)) {
  // T is TString
}

Back to Home