Socket
Socket
Sign inDemoInstall

@sinclair/typebox

Package Overview
Dependencies
0
Maintainers
1
Versions
306
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sinclair/typebox

JSONSchema Type Builder with Static Type Resolution for TypeScript


Version published
Maintainers
1
Install size
461 kB
Created

Package description

What is @sinclair/typebox?

The @sinclair/typebox package is a TypeScript utility designed to create type-safe schemas with a consistent syntax. It is primarily used for defining data structures with TypeScript types and validating data at runtime using a separate validation library like Ajv.

What are @sinclair/typebox's main functionalities?

Type Creation

Allows the creation of TypeScript types for various data structures such as strings, numbers, objects, arrays, etc. The created types can be used for compile-time type checking and runtime validation.

{"const T = Type.String()"}

Type Composition

Enables the composition of complex types by combining simpler types. This is useful for defining the shape of objects, with optional and required fields.

{"const UserType = Type.Object({ name: Type.String(), age: Type.Optional(Type.Number()) })"}

Type Validation

Provides a way to validate data at runtime against the defined types using a validation library like Ajv. This ensures that the data conforms to the specified schema.

{"const T = Type.String(); const validate = ajv.compile(T); const isValid = validate('hello');"}

Other packages similar to @sinclair/typebox

Readme

Source

TypeBox

JSON Schema Type Builder with Static Type Resolution for TypeScript



npm version Downloads Build License

Install

Npm
$ npm install @sinclair/typebox --save
Deno
import { Static, Type } from 'npm:@sinclair/typebox'
Esm
import { Static, Type } from 'https://esm.sh/@sinclair/typebox'

Example

import { Static, Type } from '@sinclair/typebox'

const T = Type.Object({                              // const T = {
  x: Type.Number(),                                  //   type: 'object',
  y: Type.Number(),                                  //   required: ['x', 'y', 'z'],
  z: Type.Number()                                   //   properties: {
})                                                   //     x: { type: 'number' },
                                                     //     y: { type: 'number' },
                                                     //     z: { type: 'number' }
                                                     //   }
                                                     // }

type T = Static<typeof T>                            // type T = {
                                                     //   x: number,
                                                     //   y: number,
                                                     //   z: number
                                                     // }

Overview

TypeBox is a runtime type builder that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type assertion rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.

This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.

License MIT

Contents

Usage

The following shows general usage.

import { Static, Type } from '@sinclair/typebox'

//--------------------------------------------------------------------------------------------
//
// Let's say you have the following type ...
//
//--------------------------------------------------------------------------------------------

type T = {
  id: string,
  name: string,
  timestamp: number
}

//--------------------------------------------------------------------------------------------
//
// ... you can express this type in the following way.
//
//--------------------------------------------------------------------------------------------

const T = Type.Object({                              // const T = {
  id: Type.String(),                                 //   type: 'object',
  name: Type.String(),                               //   properties: {
  timestamp: Type.Integer()                          //     id: {
})                                                   //       type: 'string'
                                                     //     },
                                                     //     name: {
                                                     //       type: 'string'
                                                     //     },
                                                     //     timestamp: {
                                                     //       type: 'integer'
                                                     //     }
                                                     //   },
                                                     //   required: [
                                                     //     'id',
                                                     //     'name',
                                                     //     'timestamp'
                                                     //   ]
                                                     // }

//--------------------------------------------------------------------------------------------
//
// ... then infer back to the original static type this way.
//
//--------------------------------------------------------------------------------------------

type T = Static<typeof T>                            // type T = {
                                                     //   id: string,
                                                     //   name: string,
                                                     //   timestamp: number
                                                     // }

//--------------------------------------------------------------------------------------------
//
// ... then use the type both as JSON schema and as a TypeScript type.
//
//--------------------------------------------------------------------------------------------

import { Value } from '@sinclair/typebox/value'

function receive(value: T) {                         // ... as a Static Type

  if(Value.Check(T, value)) {                        // ... as a JSON Schema

    // ok...
  }
}

Types

TypeBox types are JSON schema fragments that can be composed into more complex types. Each fragment is structured such that a JSON schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox provides a set of Standard types which are used create JSON schema compliant schematics as well as an Extended type set used to create schematics for constructs native to JavaScript.

Standard Types

The following table lists the Standard TypeBox types. These types are fully compatible with the JSON Schema Draft 6 specification.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ TypeBox                        ā”‚ TypeScript                  ā”‚ JSON Schema                    ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Any()           ā”‚ type T = any                ā”‚ const T = { }                  ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Unknown()       ā”‚ type T = unknown            ā”‚ const T = { }                  ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.String()        ā”‚ type T = string             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'string'               ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Number()        ā”‚ type T = number             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'number'               ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Integer()       ā”‚ type T = number             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'integer'              ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Boolean()       ā”‚ type T = boolean            ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'boolean'              ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Null()          ā”‚ type T = null               ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'null'                 ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Literal(42)     ā”‚ type T = 42                 ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   const: 42,                   ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'number'               ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Array(          ā”‚ type T = number[]           ā”‚ const T = {                    ā”‚
ā”‚   Type.Number()                ā”‚                             ā”‚   type: 'array',               ā”‚
ā”‚ )                              ā”‚                             ā”‚   items: {                     ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'number'             ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Object({        ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   x: Type.Number(),            ā”‚   x: number,                ā”‚   type: 'object',              ā”‚
ā”‚   y: Type.Number()             ā”‚   y: number                 ā”‚   required: ['x', 'y'],        ā”‚
ā”‚ })                             ā”‚ }                           ā”‚   properties: {                ā”‚
ā”‚                                ā”‚                             ā”‚     x: {                       ā”‚
ā”‚                                ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     },                         ā”‚
ā”‚                                ā”‚                             ā”‚     y: {                       ā”‚
ā”‚                                ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Tuple([         ā”‚ type T = [number, number]   ā”‚ const T = {                    ā”‚
ā”‚   Type.Number(),               ā”‚                             ā”‚   type: 'array',               ā”‚
ā”‚   Type.Number()                ā”‚                             ā”‚   items: [{                    ā”‚
ā”‚ ])                             ā”‚                             ā”‚      type: 'number'            ā”‚
ā”‚                                ā”‚                             ā”‚   }, {                         ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'number'             ā”‚
ā”‚                                ā”‚                             ā”‚   }],                          ā”‚
ā”‚                                ā”‚                             ā”‚   additionalItems: false,      ā”‚
ā”‚                                ā”‚                             ā”‚   minItems: 2,                 ā”‚
ā”‚                                ā”‚                             ā”‚   maxItems: 2                  ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ enum Foo {                     ā”‚ enum Foo {                  ā”‚ const T = {                    ā”‚
ā”‚   A,                           ā”‚   A,                        ā”‚   anyOf: [{                    ā”‚
ā”‚   B                            ā”‚   B                         ā”‚     type: 'number',            ā”‚
ā”‚ }                              ā”‚ }                           ā”‚     const: 0                   ā”‚
ā”‚                                ā”‚                             ā”‚   }, {                         ā”‚
ā”‚ const T = Type.Enum(Foo)       ā”‚ type T = Foo                ā”‚     type: 'number',            ā”‚
ā”‚                                ā”‚                             ā”‚     const: 1                   ā”‚
ā”‚                                ā”‚                             ā”‚   }]                           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.KeyOf(          ā”‚ type T = keyof {            ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number,                ā”‚   anyOf: [{                    ā”‚
ā”‚     x: Type.Number(),          ā”‚   y: number                 ā”‚     type: 'string',            ā”‚
ā”‚     y: Type.Number()           ā”‚ }                           ā”‚     const: 'x'                 ā”‚
ā”‚   })                           ā”‚                             ā”‚   }, {                         ā”‚
ā”‚ )                              ā”‚                             ā”‚     type: 'string',            ā”‚
ā”‚                                ā”‚                             ā”‚     const: 'y'                 ā”‚
ā”‚                                ā”‚                             ā”‚   }]                           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Union([         ā”‚ type T = string | number    ā”‚ const T = {                    ā”‚
ā”‚   Type.String(),               ā”‚                             ā”‚   anyOf: [{                    ā”‚
ā”‚   Type.Number()                ā”‚                             ā”‚      type: 'string'            ā”‚
ā”‚ ])                             ā”‚                             ā”‚   }, {                         ā”‚
ā”‚                                ā”‚                             ā”‚      type: 'number'            ā”‚
ā”‚                                ā”‚                             ā”‚   }]                           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Intersect([     ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number                 ā”‚   allOf: [{                    ā”‚
ā”‚     x: Type.Number()           ā”‚ } & {                       ā”‚     type: 'object',            ā”‚
ā”‚   }),                          ā”‚   y: number                 ā”‚     required: ['x'],           ā”‚
ā”‚   Type.Object({                ā”‚ }                           ā”‚     properties: {              ā”‚
ā”‚     y: Type.Number()           ā”‚                             ā”‚       x: {                     ā”‚
ā”‚   ])                           ā”‚                             ā”‚         type: 'number'         ā”‚
ā”‚ ])                             ā”‚                             ā”‚       }                        ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }, {                         ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'object',            |
ā”‚                                ā”‚                             ā”‚     required: ['y'],           ā”‚
ā”‚                                ā”‚                             ā”‚     properties: {              ā”‚
ā”‚                                ā”‚                             ā”‚       y: {                     ā”‚
ā”‚                                ā”‚                             ā”‚         type: 'number'         ā”‚
ā”‚                                ā”‚                             ā”‚       }                        ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }]                           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Composite([     ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number                 ā”‚   type: 'object',              ā”‚
ā”‚     x: Type.Number()           ā”‚ } & {                       ā”‚   required: ['x', 'y'],        ā”‚
ā”‚   }),                          ā”‚   y: number                 ā”‚   properties: {                ā”‚
ā”‚   Type.Object({                ā”‚ }                           ā”‚     x: {                       ā”‚
ā”‚     y: Type.Number()           ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚   })                           ā”‚                             ā”‚     },                         ā”‚
ā”‚ ])                             ā”‚                             ā”‚     y: {                       ā”‚
ā”‚                                ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Never()         ā”‚ type T = never              ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   not: {}                      ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Not(            | type T = unknown            ā”‚ const T = {                    ā”‚
ā”‚   Type.String()                ā”‚                             ā”‚   not: {                       ā”‚
ā”‚ )                              ā”‚                             ā”‚     type: 'string'             ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Extends(        ā”‚ type T =                    ā”‚ const T = {                    ā”‚
ā”‚   Type.String(),               ā”‚  string extends number      ā”‚   const: false,                ā”‚
ā”‚   Type.Number(),               ā”‚  true : false               ā”‚   type: 'boolean'              ā”‚
ā”‚   Type.Literal(true),          ā”‚                             ā”‚ }                              ā”‚
ā”‚   Type.Literal(false)          ā”‚                             ā”‚                                ā”‚
ā”‚ )                              ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Extract(        ā”‚ type T = Extract<           ā”‚ const T = {                    ā”‚
ā”‚   Type.Union([                 ā”‚   string | number,          ā”‚   type: 'string'               ā”‚
ā”‚     Type.String(),             ā”‚   string                    ā”‚ }                              ā”‚
ā”‚     Type.Number(),             ā”‚ >                           ā”‚                                ā”‚
ā”‚   ]),                          ā”‚                             ā”‚                                ā”‚
ā”‚   Type.String()                ā”‚                             ā”‚                                ā”‚
ā”‚ )                              ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Exclude(        ā”‚ type T = Exclude<           ā”‚ const T = {                    ā”‚
ā”‚   Type.Union([                 ā”‚   string | number,          ā”‚   type: 'number'               ā”‚
ā”‚     Type.String(),             ā”‚   string                    ā”‚ }                              ā”‚
ā”‚     Type.Number(),             ā”‚ >                           ā”‚                                ā”‚
ā”‚   ]),                          ā”‚                             ā”‚                                ā”‚
ā”‚   Type.String()                ā”‚                             ā”‚                                ā”‚
ā”‚ )                              ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const U = Type.Union([         ā”‚ type U = 'open' | 'close'   ā”‚ const T = {                    ā”‚
ā”‚   Type.Literal('open'),        ā”‚                             ā”‚   type: 'string',              ā”‚
ā”‚   Type.Literal('close')        ā”‚ type T = `on${U}`           ā”‚   pattern: '^on(open|close)$'  ā”‚
ā”‚ ])                             ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚ const T = Type                 ā”‚                             ā”‚                                ā”‚
ā”‚   .TemplateLiteral([           ā”‚                             ā”‚                                ā”‚
ā”‚      Type.Literal('on'),       ā”‚                             ā”‚                                ā”‚
ā”‚      U                         ā”‚                             ā”‚                                ā”‚
ā”‚   ])                           ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Record(         ā”‚ type T = Record<            ā”‚ const T = {                    ā”‚
ā”‚   Type.String(),               ā”‚   string,                   ā”‚   type: 'object',              ā”‚
ā”‚   Type.Number()                ā”‚   number                    ā”‚   patternProperties: {         ā”‚
ā”‚ )                              ā”‚ >                           ā”‚     '^.*$': {                  ā”‚
ā”‚                                ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Partial(        ā”‚ type T = Partial<{          ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number,                ā”‚   type: 'object',              ā”‚
ā”‚     x: Type.Number(),          ā”‚   y: number                 ā”‚   properties: {                ā”‚
ā”‚     y: Type.Number()           | }>                          ā”‚     x: {                       ā”‚
ā”‚   })                           ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚ )                              ā”‚                             ā”‚     },                         ā”‚
ā”‚                                ā”‚                             ā”‚     y: {                       ā”‚
ā”‚                                ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Required(       ā”‚ type T = Required<{         ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x?: number,               ā”‚   type: 'object',              ā”‚
ā”‚     x: Type.Optional(          ā”‚   y?: number                ā”‚   required: ['x', 'y'],        ā”‚
ā”‚       Type.Number()            | }>                          ā”‚   properties: {                ā”‚
ā”‚     ),                         ā”‚                             ā”‚     x: {                       ā”‚
ā”‚     y: Type.Optional(          ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚       Type.Number()            ā”‚                             ā”‚     },                         ā”‚
ā”‚     )                          ā”‚                             ā”‚     y: {                       ā”‚
ā”‚   })                           ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚ )                              ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Pick(           ā”‚ type T = Pick<{             ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number,                ā”‚   type: 'object',              ā”‚
ā”‚     x: Type.Number(),          ā”‚   y: number                 ā”‚   required: ['x'],             ā”‚
ā”‚     y: Type.Number()           ā”‚ }, 'x'>                     ā”‚   properties: {                ā”‚
ā”‚   }), ['x']                    |                             ā”‚     x: {                       ā”‚
ā”‚ )                              ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Omit(           ā”‚ type T = Omit<{             ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number,                ā”‚   type: 'object',              ā”‚
ā”‚     x: Type.Number(),          ā”‚   y: number                 ā”‚   required: ['y'],             ā”‚
ā”‚     y: Type.Number()           ā”‚ }, 'x'>                     ā”‚   properties: {                ā”‚
ā”‚   }), ['x']                    |                             ā”‚     y: {                       ā”‚
ā”‚ )                              ā”‚                             ā”‚       type: 'number'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Index(          ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   Type.Object({                ā”‚   x: number,                ā”‚   type: 'number'               ā”‚
ā”‚     x: Type.Number(),          ā”‚   y: string                 ā”‚ }                              ā”‚
ā”‚     y: Type.String()           ā”‚ }['x']                      ā”‚                                ā”‚
ā”‚   }), ['x']                    ā”‚                             ā”‚                                ā”‚
ā”‚ )                              ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const A = Type.Tuple([         ā”‚ type A = [0, 1]             ā”‚ const T = {                    ā”‚
ā”‚   Type.Literal(0),             ā”‚ type B = [2, 3]             ā”‚   type: 'array',               ā”‚
ā”‚   Type.Literal(1)              ā”‚ type T = [...A, ...B]       ā”‚   items: [                     ā”‚
ā”‚ ])                             ā”‚                             ā”‚     { const: 0 },              ā”‚
ā”‚ const B = Type.Tuple([         ā”‚                             ā”‚     { const: 1 },              ā”‚
|   Type.Literal(2),             ā”‚                             ā”‚     { const: 2 },              ā”‚
|   Type.Literal(3)              ā”‚                             ā”‚     { const: 3 }               ā”‚
ā”‚ ])                             ā”‚                             ā”‚   ],                           ā”‚
ā”‚ const T = Type.Tuple([         ā”‚                             ā”‚   additionalItems: false,      ā”‚
|   ...Type.Rest(A),             ā”‚                             ā”‚   minItems: 4,                 ā”‚
|   ...Type.Rest(B)              ā”‚                             ā”‚   maxItems: 4                  ā”‚
ā”‚ ])                             ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Object({        ā”‚ type T = {                  ā”‚ const R = {                    ā”‚
ā”‚    x: Type.Number(),           ā”‚   x: number,                ā”‚   $ref: 'T'                    ā”‚
ā”‚    y: Type.Number()            ā”‚   y: number                 ā”‚ }                              ā”‚
ā”‚ }, { $id: 'T' })               | }                           ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚ const R = Type.Ref(T)          ā”‚ type R = T                  ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Extended Types

TypeBox provides several extended types that can be used to produce schematics for common JavaScript constructs. These types can not be used with standard JSON schema validators; but are useful to help frame schematics for RPC interfaces that may receive JSON validated data. Extended types are prefixed with the [Extended] doc comment for convenience. The following table lists the supported types.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ TypeBox                        ā”‚ TypeScript                  ā”‚ Extended Schema                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Constructor([   ā”‚ type T = new (              ā”‚ const T = {                    ā”‚
ā”‚   Type.String(),               ā”‚  arg0: string,              ā”‚   type: 'object',              ā”‚
ā”‚   Type.Number()                ā”‚  arg1: number               ā”‚   instanceOf: 'Constructor',   ā”‚
ā”‚ ], Type.Boolean())             ā”‚ ) => boolean                ā”‚   parameters: [{               ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'string'             ā”‚
ā”‚                                ā”‚                             ā”‚   }, {                         ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'number'             ā”‚
ā”‚                                ā”‚                             ā”‚   }],                          ā”‚
ā”‚                                ā”‚                             ā”‚   return: {                    ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'boolean'            ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Function([      ā”‚ type T = (                  ā”‚ const T = {                    ā”‚
|   Type.String(),               ā”‚  arg0: string,              ā”‚   type : 'object',             ā”‚
ā”‚   Type.Number()                ā”‚  arg1: number               ā”‚   instanceOf: 'Function',      ā”‚
ā”‚ ], Type.Boolean())             ā”‚ ) => boolean                ā”‚   parameters: [{               ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'string'             ā”‚
ā”‚                                ā”‚                             ā”‚   }, {                         ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'number'             ā”‚
ā”‚                                ā”‚                             ā”‚   }],                          ā”‚
ā”‚                                ā”‚                             ā”‚   return: {                    ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'boolean'            ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Promise(        ā”‚ type T = Promise<string>    ā”‚ const T = {                    ā”‚
ā”‚   Type.String()                ā”‚                             ā”‚   type: 'object',              ā”‚
ā”‚ )                              ā”‚                             ā”‚   instanceOf: 'Promise',       ā”‚
ā”‚                                ā”‚                             ā”‚   item: {                      ā”‚
ā”‚                                ā”‚                             ā”‚     type: 'string'             ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Uint8Array()    ā”‚ type T = Uint8Array         ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'object',              ā”‚
ā”‚                                ā”‚                             ā”‚   instanceOf: 'Uint8Array'     ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Date()          ā”‚ type T = Date               ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'object',              ā”‚
ā”‚                                ā”‚                             ā”‚   instanceOf: 'Date'           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Undefined()     ā”‚ type T = undefined          ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'null',                ā”‚
ā”‚                                ā”‚                             ā”‚   typeOf: 'Undefined'          ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.RegEx(/foo/)    ā”‚ type T = string             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚    type: 'string',             ā”‚
ā”‚                                ā”‚                             ā”‚    pattern: 'foo'              ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Symbol()        ā”‚ type T = symbol             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'null',                ā”‚
ā”‚                                ā”‚                             ā”‚   typeOf: 'Symbol'             ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.BigInt()        ā”‚ type T = bigint             ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'null',                ā”‚
ā”‚                                ā”‚                             ā”‚   typeOf: 'BigInt'             ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Void()          ā”‚ type T = void               ā”‚ const T = {                    ā”‚
ā”‚                                ā”‚                             ā”‚   type: 'null'                 ā”‚
ā”‚                                ā”‚                             ā”‚   typeOf: 'Void'               ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Modifiers

TypeBox provides modifiers that allow schema properties to be statically inferred as readonly or optional. The following table shows the supported modifiers and how they map between TypeScript and JSON Schema.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ TypeBox                        ā”‚ TypeScript                  ā”‚ JSON Schema                    ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Object({        ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   name: Type.Optional(         ā”‚   name?: string             ā”‚   type: 'object',              ā”‚
ā”‚     Type.String()              ā”‚ }                           ā”‚   properties: {                ā”‚
ā”‚   )                            ā”‚                             ā”‚     name: {                    ā”‚
ā”‚ })  	                         ā”‚                             ā”‚       type: 'string'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Object({        ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   name: Type.Readonly(         ā”‚   readonly name: string     ā”‚   type: 'object',              ā”‚
ā”‚     Type.String()              ā”‚ }                           ā”‚   properties: {                ā”‚
ā”‚   )                            ā”‚                             ā”‚     name: {                    ā”‚
ā”‚ })  	                         ā”‚                             ā”‚       type: 'string'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   },                           ā”‚
ā”‚                                ā”‚                             ā”‚   required: ['name']           ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ const T = Type.Object({        ā”‚ type T = {                  ā”‚ const T = {                    ā”‚
ā”‚   name: Type.ReadonlyOptional( ā”‚   readonly name?: string    ā”‚   type: 'object',              ā”‚
ā”‚     Type.String()              ā”‚ }                           ā”‚   properties: {                ā”‚
ā”‚   )                            ā”‚                             ā”‚     name: {                    ā”‚
ā”‚ })  	                         ā”‚                             ā”‚       type: 'string'           ā”‚
ā”‚                                ā”‚                             ā”‚     }                          ā”‚
ā”‚                                ā”‚                             ā”‚   }                            ā”‚
ā”‚                                ā”‚                             ā”‚ }                              ā”‚
ā”‚                                ā”‚                             ā”‚                                ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Options

You can pass JSON Schema options on the last argument of any type. Option hints specific to each type are provided for convenience.

// String must be an email
const T = Type.String({                              // const T = {
  format: 'email'                                    //   type: 'string',
})                                                   //   format: 'email'
                                                     // }

// Number must be a multiple of 2
const T = Type.Number({                              // const T = {
  multipleOf: 2                                      //  type: 'number',
})                                                   //  multipleOf: 2
                                                     // }

// Array must have at least 5 integer values
const T = Type.Array(Type.Integer(), {               // const T = {
  minItems: 5                                        //   type: 'array',
})                                                   //   minItems: 5,
                                                     //   items: {
                                                     //     type: 'integer'
                                                     //   }
                                                     // }

Generic Types

Generic types can be created with generic functions constrained to type TSchema. The following creates a generic Vector<T> type.

import { Type, Static, TSchema } from '@sinclair/typebox'

const Vector = <T extends TSchema>(t: T) => Type.Object({ x: t, y: t, z: t })

const NumberVector = Vector(Type.Number())           // const NumberVector = {
                                                     //   type: 'object',
                                                     //   required: ['x', 'y', 'z'],
                                                     //   properties: {
                                                     //     x: { type: 'number' },
                                                     //     y: { type: 'number' },
                                                     //     z: { type: 'number' }
                                                     //   }
                                                     // }

type NumberVector = Static<typeof NumberVector>      // type NumberVector = {
                                                     //   x: number,
                                                     //   y: number,
                                                     //   z: number
                                                     // }

const BooleanVector = Vector(Type.Boolean())         // const BooleanVector = {
                                                     //   type: 'object',
                                                     //   required: ['x', 'y', 'z'],
                                                     //   properties: {
                                                     //     x: { type: 'boolean' },
                                                     //     y: { type: 'boolean' },
                                                     //     z: { type: 'boolean' }
                                                     //   }
                                                     // }

type BooleanVector = Static<typeof BooleanVector>    // type BooleanVector = {
                                                     //   x: boolean,
                                                     //   y: boolean,
                                                     //   z: boolean
                                                     // }

The following creates a generic Nullable<T> type.

const Nullable = <T extends TSchema>(schema: T) => Type.Union([schema, Type.Null()])

const T = Nullable(Type.String())                   // const T = {
                                                    //   anyOf: [
                                                    //     { type: 'string' },
                                                    //     { type: 'null' }
                                                    //   ]
                                                    // }

type T = Static<typeof T>                           // type T = string | null

Reference Types

Reference types are supported with Type.Ref. The target type must specify a valid $id.

const T = Type.String({ $id: 'T' })                  // const T = {
                                                     //    $id: 'T',
                                                     //    type: 'string'
                                                     // }

const R = Type.Ref(T)                                // const R = {
                                                     //    $ref: 'T'
                                                     // }

Recursive Types

Recursive types are supported with Type.Recursive.

const Node = Type.Recursive(This => Type.Object({    // const Node = {
  id: Type.String(),                                 //   $id: 'Node',
  nodes: Type.Array(This)                            //   type: 'object',
}), { $id: 'Node' })                                 //   properties: {
                                                     //     id: {
                                                     //       type: 'string'
                                                     //     },
                                                     //     nodes: {
                                                     //       type: 'array',
                                                     //       items: {
                                                     //         $ref: 'Node'
                                                     //       }
                                                     //     }
                                                     //   },
                                                     //   required: [
                                                     //     'id',
                                                     //     'nodes'
                                                     //   ]
                                                     // }

type Node = Static<typeof Node>                      // type Node = {
                                                     //   id: string
                                                     //   nodes: Node[]
                                                     // }

function test(node: Node) {
  const id = node.nodes[0].nodes[0].id               // id is string
}

Conditional Types

TypeBox supports conditional types with Type.Extends. This type will perform a structural assignment check for the first two parameters and return a true or false type from the second two parameters. The types Type.Exclude and Type.Extract are also supported.

// TypeScript

type T0 = string extends number ? true : false       // type T0 = false

type T1 = Extract<(1 | 2 | 3), 1>                    // type T1 = 1

type T2 = Exclude<(1 | 2 | 3), 1>                    // type T2 = 2 | 3

// TypeBox

const T0 = Type.Extends(                             // const T0: TLiteral<false>
  Type.String(), 
  Type.Number(), 
  Type.Literal(true), 
  Type.Literal(false)
)

const T1 = Type.Extract(                             // const T1: TLiteral<1>
  Type.Union([
    Type.Literal(1), 
    Type.Literal(2), 
    Type.Literal(3) 
  ]), 
  Type.Literal(1)
)

const T2 = Type.Exclude(                            // const T2: TUnion<[
  Type.Union([                                      //   TLiteral<2>,
    Type.Literal(1),                                //   TLiteral<3>
    Type.Literal(2),                                // ]>
    Type.Literal(3) 
  ]), 
  Type.Literal(1)
)

Template Literal Types

TypeBox supports template literal types with Type.TemplateLiteral. This type implements an embedded DSL syntax to match the TypeScript template literal syntax. This type can also be composed by passing an array of union and literal types as parameters. The following example shows the DSL syntax.

// TypeScript

type P = `/post/${string}/user/${number}`            // type P = `/post/${string}/user/${number}`

type T = `option${'A'|'B'}`                          // type T = 'optionA' | 'optionB'

type R = Record<T, string>                           // type R = {
                                                     //   optionA: string
                                                     //   optionB: string
                                                     // }

// TypeBox

const P = Type.TemplateLiteral('/post/${string}/user/${number}')

                                                     // const P = {
                                                     //   type: 'string',
                                                     //   pattern: '^/post/(.*)/user/(0|[1-9][0-9]*)$'
                                                     // }

const T = Type.TemplateLiteral('option${A|B}')       // const T = {
                                                     //   pattern: '^option(A|B)$',
                                                     //   type: 'string'
                                                     // }

const R = Type.Record(T, Type.String())              // const R = {
                                                     //   type: 'object',
                                                     //   required: ['optionA', 'optionB'],
                                                     //   properties: {
                                                     //     optionA: {
                                                     //       type: 'string'
                                                     //     },
                                                     //     optionB: {
                                                     //       type: 'string'
                                                     //     }
                                                     //   }
                                                     // }

Indexed Access Types

TypeBox supports indexed access types using Type.Index. This type provides a consistent way to access interior property and array element types without having to extract them from the underlying schema representation. Indexed access types are supported for object, array, tuple, union and intersect types.

const T = Type.Object({                              // const T = {
  x: Type.Number(),                                  //   type: 'object',
  y: Type.String(),                                  //   required: ['x', 'y', 'z'],
  z: Type.Boolean()                                  //   properties: {
})                                                   //     x: { type: 'number' },
                                                     //     y: { type: 'string' },
                                                     //     z: { type: 'string' }
                                                     //   }
                                                     // }

const A = Type.Index(T, ['x'])                       // const A = { type: 'number' }

const B = Type.Index(T, ['x', 'y'])                  // const B = {
                                                     //   anyOf: [
                                                     //     { type: 'number' },
                                                     //     { type: 'string' }
                                                     //   ]
                                                     // }

const C = Type.Index(T, Type.KeyOf(T))               // const C = {
                                                     //   anyOf: [
                                                     //     { type: 'number' },
                                                     //     { type: 'string' },
                                                     //     { type: 'boolean' }
                                                     //   ]
                                                     // }

Not Types

TypeBox provides support for the not keyword with Type.Not. This type is synonymous with negated types which are not supported in the TypeScript language. Partial inference of this type can be attained via the intersection of T & not U (where all Not types infer as unknown). This approach can be used to narrow for broader types in the following context.

// TypeScript

type T = Exclude<number, 1 | 2 | 3>                  // all numbers except 1, 2, 3
                                                     //
                                                     // ideally expressed as: 
                                                     //
                                                     // type T = number & not (1 | 2 | 3)

// TypeBox

const T = Type.Intersect([                           // const T = {
  Type.Number(),                                     //   allOf: [
  Type.Not(Type.Union([                              //     { type: "number" },
    Type.Literal(1),                                 //     {
    Type.Literal(2),                                 //       not: {
    Type.Literal(3)                                  //         anyOf: [
  ]))                                                //           { const: 1, type: "number" },
])                                                   //           { const: 2, type: "number" },
                                                     //           { const: 3, type: "number" }
                                                     //         ]
                                                     //       }
                                                     //     }
                                                     //   ]
                                                     // }

type T = Static<typeof T>                            // inferred:
                                                     //
                                                     // type T = number & not (1 | 2 | 3)
                                                     // type T = number & unknown
                                                     // type T = number

The Not type can be used with constraints to define schematics for types that would otherwise be difficult to express.

const Even = Type.Number({ multipleOf: 2 })

const Odd = Type.Intersect([Type.Number(), Type.Not(Even)])          

Rest Types

Rest parameters are supported with Type.Rest. This function is used to extract interior type elements from tuples which enables them to compose with the JavaScript spread operator .... This type can be used for tuple concatenation as well as for variadic functions.

// TypeScript

type T = [number, number]                            // type T = [number, number]

type C = [...T, number]                              // type C = [number, number, number]

type F = (...param: C) => void                       // type F = (
                                                     //   param0: number,
                                                     //   param1: number,
                                                     //   param2: number
                                                     // ) => void

// TypeBox

const T = Type.Tuple([                               // const T: TTuple<[
  Type.Number(),                                     //   TNumber,
  Type.Number()                                      //   TNumber
])                                                   // ]>

const C = Type.Tuple([                               // const C: TTuple<[
  ...Type.Rest(T),                                   //   TNumber,
  Type.Number()                                      //   TNumber,
])                                                   //   TNumber
                                                     // ]>

const F = Type.Function(Type.Rest(C), Type.Void())   // const F: TFunction<[
                                                     //   TNumber,
                                                     //   TNumber,
                                                     //   TNumber
                                                     // ], TVoid>

Unsafe Types

Use Type.Unsafe to create custom schematics with user defined inference rules.

const T = Type.Unsafe<string>({ type: 'number' })    // const T = {
                                                     //   type: 'number'
                                                     // }

type T = Static<typeof T>                            // type T = string

The Type.Unsafe type can be useful to express specific OpenAPI schema representations.

import { Type, Static, TSchema } from '@sinclair/typebox'

// Nullable<T>

function Nullable<T extends TSchema>(schema: T) {
  return Type.Unsafe<Static<T> | null>({ ...schema, nullable: true })
}

const T = Nullable(Type.String())                    // const T = {
                                                     //   type: 'string',
                                                     //   nullable: true
                                                     // }

type T = Static<typeof T>                            // type T = string | null

// StringEnum<string[]>

function StringEnum<T extends string[]>(values: [...T]) {
  return Type.Unsafe<T[number]>({ type: 'string', enum: values })
}

const T = StringEnum(['A', 'B', 'C'])                // const T = {
                                                     //   enum: ['A', 'B', 'C']
                                                     // }

type T = Static<typeof T>                            // type T = 'A' | 'B' | 'C'

Type Guards

TypeBox provides a TypeGuard module that can be used for reflection and asserting values as types.

import { Type, TypeGuard } from '@sinclair/typebox'

const T = Type.String()

if(TypeGuard.TString(T)) {

  // T is TString
}

Strict

TypeBox schemas contain the Kind and Modifier symbol properties. These properties are used for type composition and reflection. These properties are not strictly valid JSON schema; so in some cases it may be desirable to omit them. TypeBox provides a Type.Strict function that will omit these properties if necessary.

const T = Type.Object({                              // const T = {
  name: Type.Optional(Type.String())                 //   [Kind]: 'Object',
})                                                   //   type: 'object',
                                                     //   properties: {
                                                     //     name: {
                                                     //       [Kind]: 'String',
                                                     //       type: 'string',
                                                     //       [Modifier]: 'Optional'
                                                     //     }
                                                     //   }
                                                     // }

const U = Type.Strict(T)                             // const U = {
                                                     //   type: 'object',
                                                     //   properties: {
                                                     //     name: {
                                                     //       type: 'string'
                                                     //     }
                                                     //   }
                                                     // }

Values

TypeBox provides an optional utility module that can be used to perform common operations on JavaScript values. This module includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This module is provided via optional import.

import { Value } from '@sinclair/typebox/value'

Create

Use the Create function to create a value from a type. TypeBox will use default values if specified.

const T = Type.Object({ x: Type.Number(), y: Type.Number({ default: 42 }) })

const A = Value.Create(T)                            // const A = { x: 0, y: 42 }

Clone

Use the Clone function to deeply clone a value

const A = Value.Clone({ x: 1, y: 2, z: 3 })          // const A = { x: 1, y: 2, z: 3 }

Check

Use the Check function to type check a value

const T = Type.Object({ x: Type.Number() })

const R = Value.Check(T, { x: 1 })                   // const R = true

Convert

Use the Convert function to convert a value into its target type if a reasonable conversion is possible.

const T = Type.Object({ x: Type.Number() })

const R1 = Value.Convert(T, { x: '3.14' })          // const R1 = { x: 3.14 }

const R2 = Value.Convert(T, { x: 'not a number' })  // const R2 = { x: 'not a number' }

Cast

Use the Cast function to cast a value into a type. The cast function will retain as much information as possible from the original value.

const T = Type.Object({ x: Type.Number(), y: Type.Number() }, { additionalProperties: false })

const X = Value.Cast(T, null)                        // const X = { x: 0, y: 0 }

const Y = Value.Cast(T, { x: 1 })                    // const Y = { x: 1, y: 0 }

const Z = Value.Cast(T, { x: 1, y: 2, z: 3 })        // const Z = { x: 1, y: 2 }

Equal

Use the Equal function to deeply check for value equality.

const R = Value.Equal(                               // const R = true
  { x: 1, y: 2, z: 3 },
  { x: 1, y: 2, z: 3 }
)

Hash

Use the Hash function to create a FNV1A-64 non cryptographic hash of a value.

const A = Value.Hash({ x: 1, y: 2, z: 3 })          // const A = 2910466848807138541n

const B = Value.Hash({ x: 1, y: 4, z: 3 })          // const B = 1418369778807423581n

Diff

Use the Diff function to produce a sequence of edits to transform one value into another.

const E = Value.Diff(                               // const E = [
  { x: 1, y: 2, z: 3 },                             //   { type: 'update', path: '/y', value: 4 },
  { y: 4, z: 5, w: 6 }                              //   { type: 'update', path: '/z', value: 5 },
)                                                   //   { type: 'insert', path: '/w', value: 6 },
                                                    //   { type: 'delete', path: '/x' }
                                                    // ]

Patch

Use the Patch function to apply edits

const A = { x: 1, y: 2 }

const B = { x: 3 }

const E = Value.Diff(A, B)                           // const E = [
                                                     //   { type: 'update', path: '/x', value: 3 },
                                                     //   { type: 'delete', path: '/y' }
                                                     // ]

const C = Value.Patch<typeof B>(A, E)                // const C = { x: 3 }

Errors

Use the Errors function enumerate validation errors.

const T = Type.Object({ x: Type.Number(), y: Type.Number() })

const R = [...Value.Errors(T, { x: '42' })]          // const R = [{
                                                     //   schema: { type: 'number' },
                                                     //   path: '/x',
                                                     //   value: '42',
                                                     //   message: 'Expected number'
                                                     // }, {
                                                     //   schema: { type: 'number' },
                                                     //   path: '/y',
                                                     //   value: undefined,
                                                     //   message: 'Expected number'
                                                     // }]

Mutate

Use the Mutate function to perform a deep mutable value assignment while retaining internal references.

const Y = { z: 1 }                                   // const Y = { z: 1 }

const X = { y: Y }                                   // const X = { y: { z: 1 } }

const A = { x: X }                                   // const A = { x: { y: { z: 1 } } }


Value.Mutate(A, { x: { y: { z: 2 } } })              // const A' = { x: { y: { z: 2 } } }

const R0 = A.x.y.z === 2                             // const R0 = true

const R1 = A.x.y === Y                               // const R1 = true

const R2 = A.x === X                                 // const R2 = true

Pointer

Use ValuePointer to perform mutable updates on existing values using RFC6901 JSON Pointers.

import { ValuePointer } from '@sinclair/typebox/value'

const A = { x: 0, y: 0, z: 0 }

ValuePointer.Set(A, '/x', 1)                         // const A' = { x: 1, y: 0, z: 0 }

ValuePointer.Set(A, '/y', 1)                         // const A' = { x: 1, y: 1, z: 0 }

ValuePointer.Set(A, '/z', 1)                         // const A' = { x: 1, y: 1, z: 1 }

TypeCheck

TypeBox types target JSON Schema draft 6 so are compatible with any validator that supports this specification. TypeBox also provides a built in type checking compiler designed specifically for high performance compilation and value assertion.

The following sections detail using Ajv and TypeBox's compiler infrastructure.

Ajv

The following shows the recommended setup for Ajv.

$ npm install ajv ajv-formats --save
import { Type }   from '@sinclair/typebox'
import addFormats from 'ajv-formats'
import Ajv        from 'ajv'

const ajv = addFormats(new Ajv({}), [
  'date-time',
  'time',
  'date',
  'email',
  'hostname',
  'ipv4',
  'ipv6',
  'uri',
  'uri-reference',
  'uuid',
  'uri-template',
  'json-pointer',
  'relative-json-pointer',
  'regex'
])

const C = ajv.compile(Type.Object({
  x: Type.Number(),
  y: Type.Number(),
  z: Type.Number()
}))

const R = C({ x: 1, y: 2, z: 3 })                    // const R = true

TypeCompiler

The TypeBox TypeCompiler is a high performance JIT compiler that transforms TypeBox types into optimized JavaScript validation routines. The compiler is tuned for fast compilation as well as fast value assertion. It is designed to serve as a validation backend that can be integrated into larger applications; but can also be used as a general purpose validator.

The TypeCompiler is provided as an optional import.

import { TypeCompiler } from '@sinclair/typebox/compiler'

Use the Compile(...) function to compile a type. Note that compilation is an expensive operation that should typically be performed once per type during application start up. TypeBox does not cache previously compiled types, so applications are expected to hold references to each compiled type for the lifetime of the application.

const C = TypeCompiler.Compile(Type.Object({         // const C: TypeCheck<TObject<{
  x: Type.Number(),                                  //     x: TNumber;
  y: Type.Number(),                                  //     y: TNumber;
  z: Type.Number()                                   //     z: TNumber;
}))                                                  // }>>

const R = C.Check({ x: 1, y: 2, z: 3 })              // const R = true

Use the Errors(...) function to produce diagnostic errors for a value. The Errors(...) function will return an iterator that if enumerated; will perform an exhaustive check across the entire value and yield any error found. For performance, this function should only be called after failed Check(...). Applications may also choose to yield only the first value to avoid exhaustive error generation.

const C = TypeCompiler.Compile(Type.Object({         // const C: TypeCheck<TObject<{
  x: Type.Number(),                                  //     x: TNumber;
  y: Type.Number(),                                  //     y: TNumber;
  z: Type.Number()                                   //     z: TNumber;
}))                                                  // }>>

const value = { }

const errors = [...C.Errors(value)]                  // const errors = [{
                                                     //   schema: { type: 'number' },
                                                     //   path: '/x',
                                                     //   value: undefined,
                                                     //   message: 'Expected number'
                                                     // }, {
                                                     //   schema: { type: 'number' },
                                                     //   path: '/y',
                                                     //   value: undefined,
                                                     //   message: 'Expected number'
                                                     // }, {
                                                     //   schema: { type: 'number' },
                                                     //   path: '/z',
                                                     //   value: undefined,
                                                     //   message: 'Expected number'
                                                     // }]

Compiled routines can be inspected with the .Code() function.

const C = TypeCompiler.Compile(Type.String())        // const C: TypeCheck<TString>

console.log(C.Code())                                // return function check(value) {
                                                     //   return (
                                                     //     (typeof value === 'string')
                                                     //   )
                                                     // }

TypeSystem

The TypeBox TypeSystem module provides functionality to define types above and beyond the Standard and Extended type sets as well as control various assertion policies. Configurations made to the TypeSystem module are observed by both TypeCompiler and Value modules.

The TypeSystem module is provided as an optional import.

import { TypeSystem } from '@sinclair/typebox/system'

Types

Use the Type(...) function to create custom types. This function lets you specify custom value assertion logic and will return a type factory function which is used to instance the type. This function accepts two generic arguments, the first is the inference type, the second is options used to constrain the type. The following creates a Vector type.

type VectorOptions = { abs: boolean }

type Vector = { x: number, y: number }

const Vector = TypeSystem.Type<Vector, VectorOptions>('Vector', (options, value) => {
  return (
    typeof value === 'object' && value !== null &&
    'x' in value && typeof value.x === 'number' &&
    'y' in value && typeof value.y === 'number' &&
    (options.abs ? (value.x === Math.abs(value.x) && value.y === Math.abs(value.y)) : true)
  )
})

const T = Vector({ abs: true })

type T = Static<typeof T>                            // type T = Vector

const R1 = Value.Check(T, { x: 1, y: 1 })            // const R1 = true

const R2 = Value.Check(T, { x: 1, y: '1' })          // const R2 = false

const R3 = Value.Check(T, { x: 1, y: -1 })           // const R3 = false

Formats

Use the Format(...) function to create a custom string format. The following creates a format that checks for lowercase strings.

TypeSystem.Format('lowercase', value => value === value.toLowerCase()) // format should be lowercase

const T = Type.String({ format: 'lowercase' })

const A = Value.Check(T, 'Hello')                    // const A = false

const B = Value.Check(T, 'hello')                    // const B = true

Policies

TypeBox validates using standard JSON Schema assertion policies by default. It is possible to override some of these policies to have TypeBox assert inline with TypeScript static assertion rules. The following policy overrides are available.

// Disallow undefined values for optional properties (default is false)
//
// const A: { x?: number } = { x: undefined } - disallowed when enabled

TypeSystem.ExactOptionalPropertyTypes = true

// Allow arrays to validate as object types (default is false)
//
// const A: {} = [] - allowed in TS

TypeSystem.AllowArrayObjects = true

// Allow numeric values to be NaN or + or - Infinity (default is false)
//
// const A: number = NaN - allowed in TS

TypeSystem.AllowNaN = true

Workbench

TypeBox offers a web based code generation tool that can be used to convert TypeScript types into TypeBox types as well as a variety of other runtime type representations.

Workbench Link Here

Ecosystem

The following is a list of community packages that provide general tooling and framework integration support for TypeBox.

PackageDescription
elysiaFast and friendly Bun web framework
fastify-type-provider-typeboxFastify TypeBox integration with the Fastify Type Provider
feathersjsThe API and real-time application framework
fetch-typeboxDrop-in replacement for fetch that brings easy integration with TypeBox
schema2typeboxCreating TypeBox code from JSON schemas
ts2typeboxCreating TypeBox code from Typescript types
typebox-clientType safe http client library for Fastify
typebox-validatorsAdvanced validators supporting discriminated and heterogeneous unions

Benchmark

This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running npm run benchmark. The results below show for Ajv version 8.12.0 running on Node 20.0.0.

For additional comparative benchmarks, please refer to typescript-runtime-type-benchmarks.

Compile

This benchmark measures compilation performance for varying types. You can review this benchmark here.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚          (index)           ā”‚ Iterations ā”‚     Ajv      ā”‚ TypeCompiler ā”‚ Performance  ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ Literal_String             ā”‚    1000    ā”‚ '    227 ms' ā”‚ '      7 ms' ā”‚ '   32.43 x' ā”‚
ā”‚ Literal_Number             ā”‚    1000    ā”‚ '    180 ms' ā”‚ '      6 ms' ā”‚ '   30.00 x' ā”‚
ā”‚ Literal_Boolean            ā”‚    1000    ā”‚ '    152 ms' ā”‚ '      5 ms' ā”‚ '   30.40 x' ā”‚
ā”‚ Primitive_Number           ā”‚    1000    ā”‚ '    161 ms' ā”‚ '      6 ms' ā”‚ '   26.83 x' ā”‚
ā”‚ Primitive_String           ā”‚    1000    ā”‚ '    150 ms' ā”‚ '      8 ms' ā”‚ '   18.75 x' ā”‚
ā”‚ Primitive_String_Pattern   ā”‚    1000    ā”‚ '    202 ms' ā”‚ '      9 ms' ā”‚ '   22.44 x' ā”‚
ā”‚ Primitive_Boolean          ā”‚    1000    ā”‚ '    133 ms' ā”‚ '      3 ms' ā”‚ '   44.33 x' ā”‚
ā”‚ Primitive_Null             ā”‚    1000    ā”‚ '    147 ms' ā”‚ '      3 ms' ā”‚ '   49.00 x' ā”‚
ā”‚ Object_Unconstrained       ā”‚    1000    ā”‚ '   1145 ms' ā”‚ '     31 ms' ā”‚ '   36.94 x' ā”‚
ā”‚ Object_Constrained         ā”‚    1000    ā”‚ '   1241 ms' ā”‚ '     26 ms' ā”‚ '   47.73 x' ā”‚
ā”‚ Object_Vector3             ā”‚    1000    ā”‚ '    407 ms' ā”‚ '      7 ms' ā”‚ '   58.14 x' ā”‚
ā”‚ Object_Box3D               ā”‚    1000    ā”‚ '   1781 ms' ā”‚ '     27 ms' ā”‚ '   65.96 x' ā”‚
ā”‚ Tuple_Primitive            ā”‚    1000    ā”‚ '    489 ms' ā”‚ '     13 ms' ā”‚ '   37.62 x' ā”‚
ā”‚ Tuple_Object               ā”‚    1000    ā”‚ '   1278 ms' ā”‚ '     34 ms' ā”‚ '   37.59 x' ā”‚
ā”‚ Composite_Intersect        ā”‚    1000    ā”‚ '    613 ms' ā”‚ '     16 ms' ā”‚ '   38.31 x' ā”‚
ā”‚ Composite_Union            ā”‚    1000    ā”‚ '    543 ms' ā”‚ '     18 ms' ā”‚ '   30.17 x' ā”‚
ā”‚ Math_Vector4               ā”‚    1000    ā”‚ '    819 ms' ā”‚ '     13 ms' ā”‚ '   63.00 x' ā”‚
ā”‚ Math_Matrix4               ā”‚    1000    ā”‚ '    407 ms' ā”‚ '      7 ms' ā”‚ '   58.14 x' ā”‚
ā”‚ Array_Primitive_Number     ā”‚    1000    ā”‚ '    372 ms' ā”‚ '      6 ms' ā”‚ '   62.00 x' ā”‚
ā”‚ Array_Primitive_String     ā”‚    1000    ā”‚ '    329 ms' ā”‚ '      6 ms' ā”‚ '   54.83 x' ā”‚
ā”‚ Array_Primitive_Boolean    ā”‚    1000    ā”‚ '    313 ms' ā”‚ '      3 ms' ā”‚ '  104.33 x' ā”‚
ā”‚ Array_Object_Unconstrained ā”‚    1000    ā”‚ '   1780 ms' ā”‚ '     20 ms' ā”‚ '   89.00 x' ā”‚
ā”‚ Array_Object_Constrained   ā”‚    1000    ā”‚ '   1494 ms' ā”‚ '     21 ms' ā”‚ '   71.14 x' ā”‚
ā”‚ Array_Tuple_Primitive      ā”‚    1000    ā”‚ '    917 ms' ā”‚ '     10 ms' ā”‚ '   91.70 x' ā”‚
ā”‚ Array_Tuple_Object         ā”‚    1000    ā”‚ '   1666 ms' ā”‚ '     13 ms' ā”‚ '  128.15 x' ā”‚
ā”‚ Array_Composite_Intersect  ā”‚    1000    ā”‚ '    791 ms' ā”‚ '     18 ms' ā”‚ '   43.94 x' ā”‚
ā”‚ Array_Composite_Union      ā”‚    1000    ā”‚ '    833 ms' ā”‚ '     17 ms' ā”‚ '   49.00 x' ā”‚
ā”‚ Array_Math_Vector4         ā”‚    1000    ā”‚ '   1161 ms' ā”‚ '     15 ms' ā”‚ '   77.40 x' ā”‚
ā”‚ Array_Math_Matrix4         ā”‚    1000    ā”‚ '    697 ms' ā”‚ '     10 ms' ā”‚ '   69.70 x' ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Validate

This benchmark measures validation performance for varying types. You can review this benchmark here.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚          (index)           ā”‚ Iterations ā”‚  ValueCheck  ā”‚     Ajv      ā”‚ TypeCompiler ā”‚ Performance  ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ Literal_String             ā”‚  1000000   ā”‚ '     25 ms' ā”‚ '      5 ms' ā”‚ '      4 ms' ā”‚ '    1.25 x' ā”‚
ā”‚ Literal_Number             ā”‚  1000000   ā”‚ '     19 ms' ā”‚ '     18 ms' ā”‚ '      9 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Literal_Boolean            ā”‚  1000000   ā”‚ '     18 ms' ā”‚ '     18 ms' ā”‚ '      9 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Primitive_Number           ā”‚  1000000   ā”‚ '     26 ms' ā”‚ '     18 ms' ā”‚ '      9 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Primitive_String           ā”‚  1000000   ā”‚ '     25 ms' ā”‚ '     19 ms' ā”‚ '     10 ms' ā”‚ '    1.90 x' ā”‚
ā”‚ Primitive_String_Pattern   ā”‚  1000000   ā”‚ '    160 ms' ā”‚ '     42 ms' ā”‚ '     36 ms' ā”‚ '    1.17 x' ā”‚
ā”‚ Primitive_Boolean          ā”‚  1000000   ā”‚ '     24 ms' ā”‚ '     18 ms' ā”‚ '      9 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Primitive_Null             ā”‚  1000000   ā”‚ '     24 ms' ā”‚ '     19 ms' ā”‚ '      9 ms' ā”‚ '    2.11 x' ā”‚
ā”‚ Object_Unconstrained       ā”‚  1000000   ā”‚ '   1111 ms' ā”‚ '     34 ms' ā”‚ '     24 ms' ā”‚ '    1.42 x' ā”‚
ā”‚ Object_Constrained         ā”‚  1000000   ā”‚ '   1262 ms' ā”‚ '     51 ms' ā”‚ '     37 ms' ā”‚ '    1.38 x' ā”‚
ā”‚ Object_Vector3             ā”‚  1000000   ā”‚ '    445 ms' ā”‚ '     23 ms' ā”‚ '     13 ms' ā”‚ '    1.77 x' ā”‚
ā”‚ Object_Box3D               ā”‚  1000000   ā”‚ '   2029 ms' ā”‚ '     66 ms' ā”‚ '     48 ms' ā”‚ '    1.38 x' ā”‚
ā”‚ Object_Recursive           ā”‚  1000000   ā”‚ '   5121 ms' ā”‚ '    464 ms' ā”‚ '    156 ms' ā”‚ '    2.97 x' ā”‚
ā”‚ Tuple_Primitive            ā”‚  1000000   ā”‚ '    158 ms' ā”‚ '     22 ms' ā”‚ '     12 ms' ā”‚ '    1.83 x' ā”‚
ā”‚ Tuple_Object               ā”‚  1000000   ā”‚ '    761 ms' ā”‚ '     30 ms' ā”‚ '     18 ms' ā”‚ '    1.67 x' ā”‚
ā”‚ Composite_Intersect        ā”‚  1000000   ā”‚ '    828 ms' ā”‚ '     24 ms' ā”‚ '     13 ms' ā”‚ '    1.85 x' ā”‚
ā”‚ Composite_Union            ā”‚  1000000   ā”‚ '    529 ms' ā”‚ '     22 ms' ā”‚ '     13 ms' ā”‚ '    1.69 x' ā”‚
ā”‚ Math_Vector4               ā”‚  1000000   ā”‚ '    252 ms' ā”‚ '     22 ms' ā”‚ '     11 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Math_Matrix4               ā”‚  1000000   ā”‚ '   1024 ms' ā”‚ '     38 ms' ā”‚ '     27 ms' ā”‚ '    1.41 x' ā”‚
ā”‚ Array_Primitive_Number     ā”‚  1000000   ā”‚ '    264 ms' ā”‚ '     22 ms' ā”‚ '     11 ms' ā”‚ '    2.00 x' ā”‚
ā”‚ Array_Primitive_String     ā”‚  1000000   ā”‚ '    240 ms' ā”‚ '     20 ms' ā”‚ '     13 ms' ā”‚ '    1.54 x' ā”‚
ā”‚ Array_Primitive_Boolean    ā”‚  1000000   ā”‚ '    137 ms' ā”‚ '     21 ms' ā”‚ '     13 ms' ā”‚ '    1.62 x' ā”‚
ā”‚ Array_Object_Unconstrained ā”‚  1000000   ā”‚ '   6050 ms' ā”‚ '     66 ms' ā”‚ '     55 ms' ā”‚ '    1.20 x' ā”‚
ā”‚ Array_Object_Constrained   ā”‚  1000000   ā”‚ '   5954 ms' ā”‚ '    124 ms' ā”‚ '    116 ms' ā”‚ '    1.07 x' ā”‚
ā”‚ Array_Object_Recursive     ā”‚  1000000   ā”‚ '  21074 ms' ā”‚ '   1611 ms' ā”‚ '    626 ms' ā”‚ '    2.57 x' ā”‚
ā”‚ Array_Tuple_Primitive      ā”‚  1000000   ā”‚ '    683 ms' ā”‚ '     37 ms' ā”‚ '     30 ms' ā”‚ '    1.23 x' ā”‚
ā”‚ Array_Tuple_Object         ā”‚  1000000   ā”‚ '   3366 ms' ā”‚ '     69 ms' ā”‚ '     54 ms' ā”‚ '    1.28 x' ā”‚
ā”‚ Array_Composite_Intersect  ā”‚  1000000   ā”‚ '   3285 ms' ā”‚ '     45 ms' ā”‚ '     36 ms' ā”‚ '    1.25 x' ā”‚
ā”‚ Array_Composite_Union      ā”‚  1000000   ā”‚ '   2229 ms' ā”‚ '     69 ms' ā”‚ '     34 ms' ā”‚ '    2.03 x' ā”‚
ā”‚ Array_Math_Vector4         ā”‚  1000000   ā”‚ '   1192 ms' ā”‚ '     38 ms' ā”‚ '     25 ms' ā”‚ '    1.52 x' ā”‚
ā”‚ Array_Math_Matrix4         ā”‚  1000000   ā”‚ '   4916 ms' ā”‚ '    111 ms' ā”‚ '     88 ms' ā”‚ '    1.26 x' ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Compression

The following table lists esbuild compiled and minified sizes for each TypeBox module.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚       (index)        ā”‚  Compiled  ā”‚  Minified  ā”‚ Compression ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ typebox/compiler     ā”‚ '130.3 kb' ā”‚ ' 58.2 kb' ā”‚  '2.24 x'   ā”‚
ā”‚ typebox/errors       ā”‚ '113.3 kb' ā”‚ ' 49.8 kb' ā”‚  '2.27 x'   ā”‚
ā”‚ typebox/system       ā”‚ ' 78.8 kb' ā”‚ ' 32.2 kb' ā”‚  '2.45 x'   ā”‚
ā”‚ typebox/value        ā”‚ '180.0 kb' ā”‚ ' 77.7 kb' ā”‚  '2.32 x'   ā”‚
ā”‚ typebox              ā”‚ ' 77.7 kb' ā”‚ ' 31.7 kb' ā”‚  '2.45 x'   ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Contribute

TypeBox is open to community contribution. Please ensure you submit an open issue before submitting your pull request. The TypeBox project preferences open community discussion prior to accepting new features.

Keywords

FAQs

Last updated on 18 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc