{"id":48073251,"url":"https://github.com/sinclairzx81/sinclair-typebox","last_synced_at":"2026-04-04T14:46:56.349Z","repository":{"id":330259140,"uuid":"1122129819","full_name":"sinclairzx81/sinclair-typebox","owner":"sinclairzx81","description":"Json Schema Type Builder with Static Type Resolution for TypeScript","archived":false,"fork":false,"pushed_at":"2026-03-28T04:08:30.000Z","size":2538,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T08:55:06.395Z","etag":null,"topics":["support","typebox"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinclairzx81.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog/0.17.1.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-24T06:38:16.000Z","updated_at":"2026-03-28T04:09:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sinclairzx81/sinclair-typebox","commit_stats":null,"previous_names":["sinclairzx81/typebox-legacy","sinclairzx81/sinclair-typebox"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/sinclairzx81/sinclair-typebox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsinclair-typebox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsinclair-typebox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsinclair-typebox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsinclair-typebox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/sinclair-typebox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fsinclair-typebox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31403612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["support","typebox"],"created_at":"2026-04-04T14:46:56.231Z","updated_at":"2026-04-04T14:46:56.334Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align='center'\u003e\n\n\u003ch1\u003eSinclair TypeBox\u003c/h1\u003e\n\n\u003cp\u003eJson Schema Type Builder with Static Type Resolution for TypeScript\u003c/p\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/sinclairzx81/sinclair-typebox/refs/heads/main/typebox.png\" /\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n[![npm version](https://badge.fury.io/js/%40sinclair%2Ftypebox.svg)](https://badge.fury.io/js/%40sinclair%2Ftypebox)\n[![Downloads](https://img.shields.io/npm/dm/%40sinclair%2Ftypebox.svg)](https://www.npmjs.com/package/%40sinclair%2Ftypebox)\n[![Build](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml/badge.svg)](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml)\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003c/div\u003e\n\n\n\u003ca name=\"Install\"\u003e\u003c/a\u003e\n\n## Install\n\nFor the latest version use [TypeBox 1.x](https://github.com/sinclairzx81/typebox) \n\n```bash\n$ npm install @sinclair/typebox                     # TypeBox 0.x - Long Term Support\n\n$ npm install typebox                               # TypeBox 1.x - Latest\n```\n\n## Example\n\n```typescript\nimport { Type, type Static } from '@sinclair/typebox'\n\nconst T = Type.Object({                              // const T = {\n  x: Type.Number(),                                  //   type: 'object',\n  y: Type.Number(),                                  //   required: ['x', 'y', 'z'],\n  z: Type.Number()                                   //   properties: {\n})                                                   //     x: { type: 'number' },\n                                                     //     y: { type: 'number' },\n                                                     //     z: { type: 'number' }\n                                                     //   }\n                                                     // }\n\ntype T = Static\u003ctypeof T\u003e                            // type T = {\n                                                     //   x: number,\n                                                     //   y: number,\n                                                     //   z: number\n                                                     // }\n```\n\n\u003ca name=\"Overview\"\u003e\u003c/a\u003e\n\n## Overview\n\nTypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.\n\nThis library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.\n\nLicense MIT\n\n## Contents\n- [Install](#install)\n- [Overview](#overview)\n- [Usage](#usage)\n- [Types](#types)\n  - [Json](#types-json)\n  - [JavaScript](#types-javascript)\n  - [Options](#types-options)\n  - [Properties](#types-properties)\n  - [Generics](#types-generics)\n  - [Recursive](#types-recursive)\n  - [Modules](#types-modules)\n  - [Template Literal](#types-template-literal)\n  - [Indexed](#types-indexed)\n  - [Mapped](#types-mapped)\n  - [Conditional](#types-conditional)\n  - [Transform](#types-transform)\n  - [Guard](#types-guard)\n  - [Unsafe](#types-unsafe)\n- [Values](#values)\n  - [Assert](#values-assert)\n  - [Create](#values-create)\n  - [Clone](#values-clone)\n  - [Check](#values-check)\n  - [Convert](#values-convert)\n  - [Default](#values-default)\n  - [Clean](#values-clean)\n  - [Cast](#values-cast)\n  - [Decode](#values-decode)\n  - [Encode](#values-decode)\n  - [Parse](#values-parse)\n  - [Equal](#values-equal)\n  - [Hash](#values-hash)\n  - [Diff](#values-diff)\n  - [Patch](#values-patch)\n  - [Errors](#values-errors)\n  - [Mutate](#values-mutate)\n  - [Pointer](#values-pointer)\n- [Syntax](#syntax)\n  - [Create](#syntax-create)\n  - [Parameters](#syntax-parameters)\n  - [Generics](#syntax-generics)\n  - [Options](#syntax-options)\n  - [NoInfer](#syntax-no-infer)\n- [TypeRegistry](#typeregistry)\n  - [Type](#typeregistry-type)\n  - [Format](#typeregistry-format)\n- [TypeCheck](#typecheck)\n  - [Ajv](#typecheck-ajv)\n  - [TypeCompiler](#typecheck-typecompiler)\n- [TypeMap](#typemap)\n  - [Usage](#typemap-usage)\n- [TypeSystem](#typesystem)\n  - [Policies](#typesystem-policies)\n- [Error Function](#error-function)\n- [Workbench](#workbench)\n- [Codegen](#codegen)\n- [Ecosystem](#ecosystem)\n- [Benchmark](#benchmark)\n  - [Compile](#benchmark-compile)\n  - [Validate](#benchmark-validate)\n  - [Compression](#benchmark-compression)\n- [Contribute](#contribute)\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n\n## Usage\n\nThe following shows general usage.\n\n```typescript\nimport { Type, type Static } from '@sinclair/typebox'\n\n//--------------------------------------------------------------------------------------------\n//\n// Let's say you have the following type ...\n//\n//--------------------------------------------------------------------------------------------\n\ntype T = {\n  id: string,\n  name: string,\n  timestamp: number\n}\n\n//--------------------------------------------------------------------------------------------\n//\n// ... you can express this type in the following way.\n//\n//--------------------------------------------------------------------------------------------\n\nconst T = Type.Object({                              // const T = {\n  id: Type.String(),                                 //   type: 'object',\n  name: Type.String(),                               //   properties: {\n  timestamp: Type.Integer()                          //     id: {\n})                                                   //       type: 'string'\n                                                     //     },\n                                                     //     name: {\n                                                     //       type: 'string'\n                                                     //     },\n                                                     //     timestamp: {\n                                                     //       type: 'integer'\n                                                     //     }\n                                                     //   },\n                                                     //   required: [\n                                                     //     'id',\n                                                     //     'name',\n                                                     //     'timestamp'\n                                                     //   ]\n                                                     // }\n\n//--------------------------------------------------------------------------------------------\n//\n// ... then infer back to the original static type this way.\n//\n//--------------------------------------------------------------------------------------------\n\ntype T = Static\u003ctypeof T\u003e                            // type T = {\n                                                     //   id: string,\n                                                     //   name: string,\n                                                     //   timestamp: number\n                                                     // }\n\n//--------------------------------------------------------------------------------------------\n//\n// ... or use the type to parse JavaScript values.\n//\n//--------------------------------------------------------------------------------------------\n\nimport { Value } from '@sinclair/typebox/value'\n\nconst R = Value.Parse(T, value)                      // const R: {\n                                                     //   id: string,\n                                                     //   name: string,\n                                                     //   timestamp: number\n                                                     // }\n```\n\n\u003ca name='types'\u003e\u003c/a\u003e\n\n## Types\n\nTypeBox types are Json Schema fragments that compose into more complex types. Each fragment is structured such that any Json Schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox offers a set of Json Types which are used to create Json Schema compliant schematics as well as a JavaScript type set used to create schematics for constructs native to JavaScript.\n\n\u003ca name='types-json'\u003e\u003c/a\u003e\n\n### Json Types\n\nThe following table lists the supported Json types. These types are fully compatible with the Json Schema Draft 7 specification.\n\n```typescript\n┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐\n│ TypeBox                        │ TypeScript                  │ Json Schema                    │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Any()           │ type T = any                │ const T = { }                  │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Unknown()       │ type T = unknown            │ const T = { }                  │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.String()        │ type T = string             │ const T = {                    │\n│                                │                             │   type: 'string'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Number()        │ type T = number             │ const T = {                    │\n│                                │                             │   type: 'number'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Integer()       │ type T = number             │ const T = {                    │\n│                                │                             │   type: 'integer'              │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Boolean()       │ type T = boolean            │ const T = {                    │\n│                                │                             │   type: 'boolean'              │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Null()          │ type T = null               │ const T = {                    │\n│                                │                             │   type: 'null'                 │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Literal(42)     │ type T = 42                 │ const T = {                    │\n│                                │                             │   const: 42,                   │\n│                                │                             │   type: 'number'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Array(          │ type T = number[]           │ const T = {                    │\n│   Type.Number()                │                             │   type: 'array',               │\n│ )                              │                             │   items: {                     │\n│                                │                             │     type: 'number'             │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Object({        │ type T = {                  │ const T = {                    │\n│   x: Type.Number(),            │   x: number,                │   type: 'object',              │\n│   y: Type.Number()             │   y: number                 │   required: ['x', 'y'],        │\n│ })                             │ }                           │   properties: {                │\n│                                │                             │     x: {                       │\n│                                │                             │       type: 'number'           │\n│                                │                             │     },                         │\n│                                │                             │     y: {                       │\n│                                │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Tuple([         │ type T = [number, number]   │ const T = {                    │\n│   Type.Number(),               │                             │   type: 'array',               │\n│   Type.Number()                │                             │   items: [{                    │\n│ ])                             │                             │     type: 'number'             │\n│                                │                             │   }, {                         │\n│                                │                             │     type: 'number'             │\n│                                │                             │   }],                          │\n│                                │                             │   additionalItems: false,      │\n│                                │                             │   minItems: 2,                 │\n│                                │                             │   maxItems: 2                  │\n│                                │                             │ }                              │\n│                                │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ enum Foo {                     │ enum Foo {                  │ const T = {                    │\n│   A,                           │   A,                        │   anyOf: [{                    │\n│   B                            │   B                         │     type: 'number',            │\n│ }                              │ }                           │     const: 0                   │\n│                                │                             │   }, {                         │\n│ const T = Type.Enum(Foo)       │ type T = Foo                │     type: 'number',            │\n│                                │                             │     const: 1                   │\n│                                │                             │   }]                           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Const({         │ type T = {                  │ const T = {                    │\n│   x: 1,                        │   readonly x: 1,            │   type: 'object',              │\n│   y: 2,                        │   readonly y: 2             │   required: ['x', 'y'],        │\n│ } as const)                    │ }                           │   properties: {                │\n│                                │                             │     x: {                       │\n│                                │                             │       type: 'number',          │\n│                                │                             │       const: 1                 │\n│                                │                             │     },                         │\n│                                │                             │     y: {                       │\n│                                │                             │       type: 'number',          │\n│                                │                             │       const: 2                 │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.KeyOf(          │ type T = keyof {            │ const T = {                    │\n│   Type.Object({                │   x: number,                │   anyOf: [{                    │\n│     x: Type.Number(),          │   y: number                 │     type: 'string',            │\n│     y: Type.Number()           │ }                           │     const: 'x'                 │\n│   })                           │                             │   }, {                         │\n│ )                              │                             │     type: 'string',            │\n│                                │                             │     const: 'y'                 │\n│                                │                             │   }]                           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Union([         │ type T = string | number    │ const T = {                    │\n│   Type.String(),               │                             │   anyOf: [{                    │\n│   Type.Number()                │                             │     type: 'string'             │\n│ ])                             │                             │   }, {                         │\n│                                │                             │     type: 'number'             │\n│                                │                             │   }]                           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Intersect([     │ type T = {                  │ const T = {                    │\n│   Type.Object({                │   x: number                 │   allOf: [{                    │\n│     x: Type.Number()           │ } \u0026 {                       │     type: 'object',            │\n│   }),                          │   y: number                 │     required: ['x'],           │\n│   Type.Object({                │ }                           │     properties: {              │\n│     y: Type.Number()           │                             │       x: {                     │\n│   })                           │                             │         type: 'number'         │\n│ ])                             │                             │       }                        │\n│                                │                             │     }                          │\n│                                │                             │   }, {                         │\n│                                │                             │     type: 'object',            |\n│                                │                             │     required: ['y'],           │\n│                                │                             │     properties: {              │\n│                                │                             │       y: {                     │\n│                                │                             │         type: 'number'         │\n│                                │                             │       }                        │\n│                                │                             │     }                          │\n│                                │                             │   }]                           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Composite([     │ type T = {                  │ const T = {                    │\n│   Type.Object({                │   x: number,                │   type: 'object',              │\n│     x: Type.Number()           │   y: number                 │   required: ['x', 'y'],        │\n│   }),                          │ }                           │   properties: {                │\n│   Type.Object({                │                             │     x: {                       │\n│     y: Type.Number()           │                             │       type: 'number'           │\n│   })                           │                             │     },                         │\n│ ])                             │                             │     y: {                       │\n│                                │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Never()         │ type T = never              │ const T = {                    │\n│                                │                             │   not: {}                      │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Not(            | type T = unknown            │ const T = {                    │\n│   Type.String()                │                             │   not: {                       │\n│ )                              │                             │     type: 'string'             │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Extends(        │ type T =                    │ const T = {                    │\n│   Type.String(),               │  string extends number      │   const: false,                │\n│   Type.Number(),               │    ? true                   │   type: 'boolean'              │\n│   Type.Literal(true),          │    : false                  │ }                              │\n│   Type.Literal(false)          │                             │                                │\n│ )                              │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Extract(        │ type T = Extract\u003c           │ const T = {                    │\n│   Type.Union([                 │   string | number,          │   type: 'string'               │\n│     Type.String(),             │   string                    │ }                              │\n│     Type.Number(),             │ \u003e                           │                                │\n│   ]),                          │                             │                                │\n│   Type.String()                │                             │                                │\n│ )                              │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Exclude(        │ type T = Exclude\u003c           │ const T = {                    │\n│   Type.Union([                 │   string | number,          │   type: 'number'               │\n│     Type.String(),             │   string                    │ }                              │\n│     Type.Number(),             │ \u003e                           │                                │\n│   ]),                          │                             │                                │\n│   Type.String()                │                             │                                │\n│ )                              │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Mapped(         │ type T = {                  │ const T = {                    │\n│   Type.Union([                 │   [_ in 'x' | 'y'] : number │   type: 'object',              │\n│     Type.Literal('x'),         │ }                           │   required: ['x', 'y'],        │\n│     Type.Literal('y')          │                             │   properties: {                │\n│   ]),                          │                             │     x: {                       │\n│   () =\u003e Type.Number()          │                             │       type: 'number'           │\n│ )                              │                             │     },                         │\n│                                │                             │     y: {                       │\n│                                │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const U = Type.Union([         │ type U = 'open' | 'close'   │ const T = {                    │\n│   Type.Literal('open'),        │                             │   type: 'string',              │\n│   Type.Literal('close')        │ type T = `on${U}`           │   pattern: '^on(open|close)$'  │\n│ ])                             │                             │ }                              │\n│                                │                             │                                │\n│ const T = Type                 │                             │                                │\n│   .TemplateLiteral([           │                             │                                │\n│      Type.Literal('on'),       │                             │                                │\n│      U                         │                             │                                │\n│   ])                           │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Record(         │ type T = Record\u003c            │ const T = {                    │\n│   Type.String(),               │   string,                   │   type: 'object',              │\n│   Type.Number()                │   number                    │   patternProperties: {         │\n│ )                              │ \u003e                           │     '^.*$': {                  │\n│                                │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Partial(        │ type T = Partial\u003c{          │ const T = {                    │\n│   Type.Object({                │   x: number,                │   type: 'object',              │\n│     x: Type.Number(),          │   y: number                 │   properties: {                │\n│     y: Type.Number()           | }\u003e                          │     x: {                       │\n│   })                           │                             │       type: 'number'           │\n│ )                              │                             │     },                         │\n│                                │                             │     y: {                       │\n│                                │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Required(       │ type T = Required\u003c{         │ const T = {                    │\n│   Type.Object({                │   x?: number,               │   type: 'object',              │\n│     x: Type.Optional(          │   y?: number                │   required: ['x', 'y'],        │\n│       Type.Number()            | }\u003e                          │   properties: {                │\n│     ),                         │                             │     x: {                       │\n│     y: Type.Optional(          │                             │       type: 'number'           │\n│       Type.Number()            │                             │     },                         │\n│     )                          │                             │     y: {                       │\n│   })                           │                             │       type: 'number'           │\n│ )                              │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Pick(           │ type T = Pick\u003c{             │ const T = {                    │\n│   Type.Object({                │   x: number,                │   type: 'object',              │\n│     x: Type.Number(),          │   y: number                 │   required: ['x'],             │\n│     y: Type.Number()           │ }, 'x'\u003e                     │   properties: {                │\n│   }), ['x']                    |                             │     x: {                       │\n│ )                              │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Omit(           │ type T = Omit\u003c{             │ const T = {                    │\n│   Type.Object({                │   x: number,                │   type: 'object',              │\n│     x: Type.Number(),          │   y: number                 │   required: ['y'],             │\n│     y: Type.Number()           │ }, 'x'\u003e                     │   properties: {                │\n│   }), ['x']                    |                             │     y: {                       │\n│ )                              │                             │       type: 'number'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Index(          │ type T = {                  │ const T = {                    │\n│   Type.Object({                │   x: number,                │   type: 'number'               │\n│     x: Type.Number(),          │   y: string                 │ }                              │\n│     y: Type.String()           │ }['x']                      │                                │\n│   }), ['x']                    │                             │                                │\n│ )                              │                             │                                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const A = Type.Tuple([         │ type A = [0, 1]             │ const T = {                    │\n│   Type.Literal(0),             │ type B = [2, 3]             │   type: 'array',               │\n│   Type.Literal(1)              │ type T = [                  │   items: [                     │\n│ ])                             │   ...A,                     │     { const: 0 },              │\n│ const B = Type.Tuple([         │   ...B                      │     { const: 1 },              │\n|   Type.Literal(2),             │ ]                           │     { const: 2 },              │\n|   Type.Literal(3)              │                             │     { const: 3 }               │\n│ ])                             │                             │   ],                           │\n│ const T = Type.Tuple([         │                             │   additionalItems: false,      │\n|   ...Type.Rest(A),             │                             │   minItems: 4,                 │\n|   ...Type.Rest(B)              │                             │   maxItems: 4                  │\n│ ])                             │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Uncapitalize(   │ type T = Uncapitalize\u003c      │ const T = {                    │\n│   Type.Literal('Hello')        │   'Hello'                   │   type: 'string',              │\n│ )                              │ \u003e                           │   const: 'hello'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Capitalize(     │ type T = Capitalize\u003c        │ const T = {                    │\n│   Type.Literal('hello')        │   'hello'                   │   type: 'string',              │\n│ )                              │ \u003e                           │   const: 'Hello'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Uppercase(      │ type T = Uppercase\u003c         │ const T = {                    │\n│   Type.Literal('hello')        │   'hello'                   │   type: 'string',              │\n│ )                              │ \u003e                           │   const: 'HELLO'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Lowercase(      │ type T = Lowercase\u003c         │ const T = {                    │\n│   Type.Literal('HELLO')        │   'HELLO'                   │   type: 'string',              │\n│ )                              │ \u003e                           │   const: 'hello'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const R = Type.Ref('T')        │ type R = unknown            │ const R = { $ref: 'T' }        │\n│                                │                             │                                │\n└────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘\n```\n\n\u003ca name='types-javascript'\u003e\u003c/a\u003e\n\n### JavaScript Types\n\nTypeBox provides an extended type set that can be used to create schematics for common JavaScript constructs. These types can not be used with any standard Json Schema validator; but can be used to frame schematics for interfaces that may receive Json validated data. JavaScript types are prefixed with the `[JavaScript]` JSDoc comment for convenience. The following table lists the supported types.\n\n```typescript\n┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐\n│ TypeBox                        │ TypeScript                  │ Extended Schema                │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Constructor([   │ type T = new (              │ const T = {                    │\n│   Type.String(),               │  arg0: string,              │   type: 'Constructor',         │\n│   Type.Number()                │  arg0: number               │   parameters: [{               │\n│ ], Type.Boolean())             │ ) =\u003e boolean                │     type: 'string'             │\n│                                │                             │   }, {                         │\n│                                │                             │     type: 'number'             │\n│                                │                             │   }],                          │\n│                                │                             │   returns: {                   │\n│                                │                             │     type: 'boolean'            │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Function([      │ type T = (                  │ const T = {                    │\n|   Type.String(),               │  arg0: string,              │   type: 'Function',            │\n│   Type.Number()                │  arg1: number               │   parameters: [{               │\n│ ], Type.Boolean())             │ ) =\u003e boolean                │     type: 'string'             │\n│                                │                             │   }, {                         │\n│                                │                             │     type: 'number'             │\n│                                │                             │   }],                          │\n│                                │                             │   returns: {                   │\n│                                │                             │     type: 'boolean'            │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Promise(        │ type T = Promise\u003cstring\u003e    │ const T = {                    │\n│   Type.String()                │                             │   type: 'Promise',             │\n│ )                              │                             │   item: {                      │\n│                                │                             │     type: 'string'             │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T =                      │ type T =                    │ const T = {                    │\n│   Type.AsyncIterator(          │   AsyncIterableIterator\u003c    │   type: 'AsyncIterator',       │\n│     Type.String()              │    string                   │   items: {                     │\n│   )                            │   \u003e                         │     type: 'string'             │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Iterator(       │ type T =                    │ const T = {                    │\n│   Type.String()                │   IterableIterator\u003cstring\u003e  │   type: 'Iterator',            │\n│ )                              │                             │   items: {                     │\n│                                │                             │     type: 'string'             │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.RegExp(/abc/i)  │ type T = string             │ const T = {                    │\n│                                │                             │   type: 'RegExp'               │\n│                                │                             │   source: 'abc'                │\n│                                │                             │   flags: 'i'                   │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Uint8Array()    │ type T = Uint8Array         │ const T = {                    │\n│                                │                             │   type: 'Uint8Array'           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Date()          │ type T = Date               │ const T = {                    │\n│                                │                             │   type: 'Date'                 │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Undefined()     │ type T = undefined          │ const T = {                    │\n│                                │                             │   type: 'undefined'            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Symbol()        │ type T = symbol             │ const T = {                    │\n│                                │                             │   type: 'symbol'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.BigInt()        │ type T = bigint             │ const T = {                    │\n│                                │                             │   type: 'bigint'               │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Void()          │ type T = void               │ const T = {                    │\n│                                │                             │   type: 'void'                 │\n│                                │                             │ }                              │\n│                                │                             │                                │\n└────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘\n```\n\n\u003ca name='types-options'\u003e\u003c/a\u003e\n\n### Options\n\nYou can pass Json Schema options on the last argument of any given type. Option hints specific to each type are provided for convenience.\n\n```typescript\n// String must be an email\nconst T = Type.String({                              // const T = {\n  format: 'email'                                    //   type: 'string',\n})                                                   //   format: 'email'\n                                                     // }\n\n// Number must be a multiple of 2\nconst T = Type.Number({                              // const T = {\n  multipleOf: 2                                      //  type: 'number',\n})                                                   //  multipleOf: 2\n                                                     // }\n\n// Array must have at least 5 integer values\nconst T = Type.Array(Type.Integer(), {               // const T = {\n  minItems: 5                                        //   type: 'array',\n})                                                   //   minItems: 5,\n                                                     //   items: {\n                                                     //     type: 'integer'\n                                                     //   }\n                                                     // }\n```\n\n\u003ca name='types-properties'\u003e\u003c/a\u003e\n\n### Properties\n\nObject properties can be modified with Readonly and Optional. The following table shows how these modifiers map between TypeScript and Json Schema.\n\n```typescript\n┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐\n│ TypeBox                        │ TypeScript                  │ Json Schema                    │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Object({        │ type T = {                  │ const T = {                    │\n│   name: Type.ReadonlyOptional( │   readonly name?: string    │   type: 'object',              │\n│     Type.String()              │ }                           │   properties: {                │\n│   )                            │                             │     name: {                    │\n│ })  \t                         │                             │       type: 'string'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Object({        │ type T = {                  │ const T = {                    │\n│   name: Type.Readonly(         │   readonly name: string     │   type: 'object',              │\n│     Type.String()              │ }                           │   properties: {                │\n│   )                            │                             │     name: {                    │\n│ })  \t                         │                             │       type: 'string'           │\n│                                │                             │     }                          │\n│                                │                             │   },                           │\n│                                │                             │   required: ['name']           │\n│                                │                             │ }                              │\n│                                │                             │                                │\n├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤\n│ const T = Type.Object({        │ type T = {                  │ const T = {                    │\n│   name: Type.Optional(         │   name?: string             │   type: 'object',              │\n│     Type.String()              │ }                           │   properties: {                │\n│   )                            │                             │     name: {                    │\n│ })  \t                         │                             │       type: 'string'           │\n│                                │                             │     }                          │\n│                                │                             │   }                            │\n│                                │                             │ }                              │\n│                                │                             │                                │\n└────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘\n```\n\n\u003ca name='types-generics'\u003e\u003c/a\u003e\n\n### Generic Types\n\nGeneric types can be created with generic functions.\n\n```typescript\nconst Nullable = \u003cT extends TSchema\u003e(T: T) =\u003e {     // type Nullable\u003cT\u003e = T | null\n  return Type.Union([T, Type.Null()])\n}\n\nconst T = Nullable(Type.String())                  // type T = Nullable\u003cstring\u003e\n```\n\n\u003ca name='types-recursive'\u003e\u003c/a\u003e\n\n### Recursive Types\n\nUse the Recursive function to create recursive types.\n\n```typescript\nconst Node = Type.Recursive(This =\u003e Type.Object({    // const Node = {\n  id: Type.String(),                                 //   $id: 'Node',\n  nodes: Type.Array(This)                            //   type: 'object',\n}), { $id: 'Node' })                                 //   properties: {\n                                                     //     id: {\n                                                     //       type: 'string'\n                                                     //     },\n                                                     //     nodes: {\n                                                     //       type: 'array',\n                                                     //       items: {\n                                                     //         $ref: 'Node'\n                                                     //       }\n                                                     //     }\n                                                     //   },\n                                                     //   required: [\n                                                     //     'id',\n                                                     //     'nodes'\n                                                     //   ]\n                                                     // }\n\ntype Node = Static\u003ctypeof Node\u003e                      // type Node = {\n                                                     //   id: string\n                                                     //   nodes: Node[]\n                                                     // }\n\nfunction test(node: Node) {\n  const id = node.nodes[0].nodes[0].id               // id is string\n}\n```\n\n\u003ca name='types-modules'\u003e\u003c/a\u003e\n\n### Module Types\n\nModule types are containers for a set of referential types. Modules act as namespaces, enabling types to reference one another via string identifiers. Modules support both singular and mutually recursive references, as well as deferred dereferencing for computed types such as Partial. Types imported from a module are expressed using the Json Schema `$defs` keyword. \n\n```typescript\nconst Module = Type.Module({\n  PartialUser: Type.Partial(Type.Ref('User')),  // TComputed\u003c'Partial', [TRef\u003c'User'\u003e]\u003e\n\n  User: Type.Object({                           // TObject\u003c{\n    id: Type.String(),                          //   user: TString,\n    name: Type.String(),                        //   name: TString,\n    email: Type.String()                        //   email: TString\n  }),                                           // }\u003e\n})\nconst User = Module.Import('User')               // const User: TImport\u003c{...}, 'User'\u003e\n\ntype User = Static\u003ctypeof User\u003e                  // type User = { \n                                                 //   id: string,\n                                                 //   name: string,\n                                                 //   email: string\n                                                 // }\n\nconst PartialUser = Module.Import('PartialUser') // const PartialUser: TImport\u003c{...}, 'PartialUser'\u003e\n\ntype PartialUser = Static\u003ctypeof PartialUser\u003e    // type PartialUser = { \n                                                 //   id?: string,\n                                                 //   name?: string,\n                                                 //   email?: string\n                                                 // }\n```\n\n\u003ca name='types-template-literal'\u003e\u003c/a\u003e\n\n### Template Literal Types\n\nTypeBox supports template literal types with the TemplateLiteral function. This type can be created using a syntax similar to the TypeScript template literal syntax or composed from exterior types. TypeBox encodes template literals as regular expressions which enables the template to be checked by Json Schema validators. This type also supports regular expression parsing that enables template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.\n\n```typescript\n// TypeScript\n\ntype K = `prop${'A'|'B'|'C'}`                        // type T = 'propA' | 'propB' | 'propC'\n\ntype R = Record\u003cK, string\u003e                           // type R = {\n                                                     //   propA: string\n                                                     //   propB: string\n                                                     //   propC: string\n                                                     // }\n\n// TypeBox\n\nconst K = Type.TemplateLiteral('prop${A|B|C}')       // const K: TTemplateLiteral\u003c[\n                                                     //   TLiteral\u003c'prop'\u003e,\n                                                     //   TUnion\u003c[\n                                                     //      TLiteral\u003c'A'\u003e,\n                                                     //      TLiteral\u003c'B'\u003e,\n                                                     //      TLiteral\u003c'C'\u003e,\n                                                     //   ]\u003e\n                                                     // ]\u003e\n\nconst R = Type.Record(K, Type.String())              // const R: TObject\u003c{\n                                                     //   propA: TString,\n                                                     //   propB: TString,\n                                                     //   propC: TString,\n                                                     // }\u003e\n```\n\n\u003ca name='types-indexed'\u003e\u003c/a\u003e\n\n### Indexed Access Types\n\nTypeBox supports indexed access types with the Index function. This function enables uniform access to interior property and element types without having to extract them from the underlying schema representation. Index types are supported for Object, Array, Tuple, Union and Intersect types.\n\n```typescript\nconst T = Type.Object({                              // type T = {\n  x: Type.Number(),                                  //   x: number,\n  y: Type.String(),                                  //   y: string,\n  z: Type.Boolean()                                  //   z: boolean\n})                                                   // }\n\nconst A = Type.Index(T, ['x'])                       // type A = T['x']\n                                                     //\n                                                     // ... evaluated as\n                                                     //\n                                                     // const A: TNumber\n\nconst B = Type.Index(T, ['x', 'y'])                  // type B = T['x' | 'y']\n                                                     //\n                                                     // ... evaluated as\n                                                     //\n                                                     // const B: TUnion\u003c[\n                                                     //   TNumber,\n                                                     //   TString,\n                                                     // ]\u003e\n\nconst C = Type.Index(T, Type.KeyOf(T))               // type C = T[keyof T]\n                                                     //\n                                                     // ... evaluated as\n                                                     // \n                                                     // const C: TUnion\u003c[\n                                                     //   TNumber,\n                                                     //   TString,\n                                                     //   TBoolean\n                                                     // ]\u003e\n```\n\n\u003ca name='types-mapped'\u003e\u003c/a\u003e\n\n### Mapped Types\n\nTypeBox supports mapped types with the Mapped function. This function accepts two arguments, the first is a union type typically derived from KeyOf, the second is a mapping function that receives a mapping key `K` that can be used to index properties of a type. The following implements a mapped type that remaps each property to be `T | null`.\n\n```typescript\nconst T = Type.Object({                              // type T = {\n  x: Type.Number(),                                  //   x: number,\n  y: Type.String(),                                  //   y: string,\n  z: Type.Boolean()                                  //   z: boolean\n})                                                   // }\n\nconst M = Type.Mapped(Type.KeyOf(T), K =\u003e {          // type M = { [K in keyof T]: T[K] | null }\n  return Type.Union([Type.Index(T, K), Type.Null()]) //\n})                                                   // ... evaluated as\n                                                     // \n                                                     // const M: TObject\u003c{\n                                                     //   x: TUnion\u003c[TNumber, TNull]\u003e,\n                                                     //   y: TUnion\u003c[TString, TNull]\u003e,\n                                                     //   z: TUnion\u003c[TBoolean, TNull]\u003e\n                                                     // }\u003e\n```\n\n\u003ca name='types-conditional'\u003e\u003c/a\u003e\n\n### Conditional Types\n\nTypeBox supports runtime conditional types with the Extends function. This function performs a structural assignability check against the first (`left`) and second (`right`) arguments and will return either the third (`true`) or fourth (`false`) argument based on the result. The conditional types Exclude and Extract are also supported. The following shows both TypeScript and TypeBox examples of conditional types.\n\n```typescript\n// Extends\nconst A = Type.Extends(                              // type A = string extends number ? 1 : 2\n  Type.String(),                                     //   \n  Type.Number(),                                     // ... evaluated as\n  Type.Literal(1),                                   //\n  Type.Literal(2)                                    // const A: TLiteral\u003c2\u003e\n)\n\n// Extract\nconst B = Type.Extract(                              // type B = Extract\u003c1 | 2 | 3, 1\u003e\n  Type.Union([                                       //\n    Type.Literal(1),                                 // ... evaluated as\n    Type.Literal(2),                                 //\n    Type.Literal(3)                                  // const B: TLiteral\u003c1\u003e\n  ]), \n  Type.Literal(1)\n)\n\n// Exclude\nconst C = Type.Exclude(                              // type C = Exclude\u003c1 | 2 | 3, 1\u003e\n  Type.Union([                                       // \n    Type.Literal(1),                                 // ... evaluated as\n    Type.Literal(2),                                 //\n    Type.Literal(3)                                  // const C: TUnion\u003c[\n  ]),                                                //   TLiteral\u003c2\u003e,\n  Type.Literal(1)                                    //   TLiteral\u003c3\u003e,\n)                                                    // ]\u003e\n```\n\n\u003ca name='types-transform'\u003e\u003c/a\u003e\n\n### Transform Types\n\nTypeBox supports value decoding and encoding with Transform types. These types work in tandem with the Encode and Decode functions available on the Value and TypeCompiler submodules. Transform types can be used to convert Json encoded values into constructs more natural to JavaScript. The following creates a Transform type to decode numbers into Dates using the Value submodule.\n\n```typescript\nimport { Value } from '@sinclair/typebox/value'\n\nconst T = Type.Transform(Type.Number())\n  .Decode(value =\u003e new Date(value))                  // decode: number to Date\n  .Encode(value =\u003e value.getTime())                  // encode: Date to number\n\nconst D = Value.Decode(T, 0)                         // const D = Date(1970-01-01T00:00:00.000Z)\nconst E = Value.Encode(T, D)                         // const E = 0\n```\nUse the StaticEncode or StaticDecode types to infer a Transform type.\n```typescript\nimport { Static, StaticDecode, StaticEncode } from '@sinclair/typebox'\n\nconst T = Type.Transform(Type.Array(Type.Number(), { uniqueItems: true }))         \n  .Decode(value =\u003e new Set(value))\n  .Encode(value =\u003e [...value])\n\ntype D = StaticDecode\u003ctypeof T\u003e                      // type D = Set\u003cnumber\u003e      \ntype E = StaticEncode\u003ctypeof T\u003e                      // type E = Array\u003cnumber\u003e\ntype T = Static\u003ctypeof T\u003e                            // type T = Array\u003cnumber\u003e\n```\n\n\u003ca name='types-unsafe'\u003e\u003c/a\u003e\n\n### Unsafe Types\n\nTypeBox supports user defined types with Unsafe. This type allows you to specify both schema representation and inference type. The following creates an Unsafe type with a number schema that infers as string.\n\n```typescript\nconst T = Type.Unsafe\u003cstring\u003e({ type: 'number' })    // const T = { type: 'number' }\n\ntype T = Static\u003ctypeof T\u003e                            // type T = string - ?\n```\nThe Unsafe type is often used to create schematics for extended specifications like OpenAPI.\n```typescript\n\nconst Nullable = \u003cT extends TSchema\u003e(schema: T) =\u003e Type.Unsafe\u003cStatic\u003cT\u003e | null\u003e({ \n  ...schema, nullable: true \n})\n\nconst T = Nullable(Type.String())                    // const T = {\n                                                     //   type: 'string',\n                                                     //   nullable: true\n                                                     // }\n\ntype T = Static\u003ctypeof T\u003e                            // type T = string | null\n\nconst StringEnum = \u003cT extends string[]\u003e(values: [...T]) =\u003e Type.Unsafe\u003cT[number]\u003e({ \n  type: 'string', enum: values \n})\nconst S = StringEnum(['A', 'B', 'C'])                // const S = {\n                                                     //   enum: ['A', 'B', 'C']\n                                                     // }\n\ntype S = Static\u003ctypeof T\u003e                            // type S = 'A' | 'B' | 'C'\n```\n\u003ca name='types-guard'\u003e\u003c/a\u003e\n\n### TypeGuard\n\nTypeBox can check its own types with the TypeGuard module. This module is written for type introspection and provides structural tests for every built-in TypeBox type. Functions of this module return `is` guards which can be used with control flow assertions to obtain schema inference for unknown values. The following guards that the value `T` is TString.\n\n```typescript\nimport { TypeGuard, Kind } from '@sinclair/typebox'\n\nconst T = { [Kind]: 'String', type: 'string' }\n\nif(TypeGuard.IsString(T)) {\n\n  // T is TString\n}\n```\n\n\u003ca name='values'\u003e\u003c/a\u003e\n\n## Values\n\nTypeBox provides an optional Value submodule that can be used to perform structural operations on JavaScript values. This submodule includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This submodule is provided via optional import.\n\n```typescript\nimport { Value } from '@sinclair/typebox/value'\n```\n\n\u003ca name='values-assert'\u003e\u003c/a\u003e\n\n### Assert\n\nUse the Assert function to assert a value is valid.\n\n```typescript\nlet value: unknown = 1\n\nValue.Assert(Type.Number(), value)                   // throws AssertError if invalid\n```\n\n\u003ca name='values-create'\u003e\u003c/a\u003e\n\n### Create\n\nUse the Create function to create a value from a type. TypeBox will use default values if specified.\n\n```typescript\nconst T = Type.Object({ x: Type.Number(), y: Type.Number({ default: 42 }) })\n\nconst A = Value.Create(T)                            // const A = { x: 0, y: 42 }\n```\n\n\u003ca name='values-clone'\u003e\u003c/a\u003e\n\n### Clone\n\nUse the Clone function to deeply clone a value.\n\n```typescript\nconst A = Value.Clone({ x: 1, y: 2, z: 3 })          // const A = { x: 1, y: 2, z: 3 }\n```\n\n\u003ca name='values-check'\u003e\u003c/a\u003e\n\n### Check\n\nUse the Check function to type check a value.\n\n```typescript\nconst T = Type.Object({ x: Type.Number() })\n\nconst R = Value.Check(T, { x: 1 })                   // const R = true\n```\n\n\u003ca name='values-convert'\u003e\u003c/a\u003e\n\n### Convert\n\nUse the Convert function to convert a value into its target type if a reasonable conversion is possible. This function may return an invalid value and should be checked before use. Its return type is `unknown`.\n\n```typescript\nconst T = Type.Object({ x: Type.Number() })\n\nconst R1 = Value.Convert(T, { x: '3.14' })           // const R1 = { x: 3.14 }\n\nconst R2 = Value.Convert(T, { x: 'not a number' })   // const R2 = { x: 'not a number' }\n```\n\n\u003ca name='values-clean'\u003e\u003c/a\u003e\n\n### Clean\n\nUse Clean to remove excess properties from a value. This function does not check the value and returns an unknown type. You should Check the result before use. Clean is a mutable operation. To avoid mutation, Clone the value first.\n\n```typescript\nconst T = Type.Object({ \n  x: Type.Number(), \n  y: Type.Number() \n})\n\nconst X = Value.Clean(T, null)                        // const 'X = null\n\nconst Y = Value.Clean(T, { x: 1 })                    // const 'Y = { x: 1 }\n\nconst Z = Value.Clean(T, { x: 1, y: 2, z: 3 })        // const 'Z = { x: 1, y: 2 }\n```\n\n\u003ca name='values-default'\u003e\u003c/a\u003e\n\n### Default\n\nUse Default to generate missing properties on a value using default schema annotations if available. This function does not check the value and returns an unknown type. You should Check the result before use. Default is a mutable operation. To avoid mutation, Clone the value first.\n\n```typescript\nconst T = Type.Object({ \n  x: Type.Number({ default: 0 }), \n  y: Type.Number({ default: 0 })\n})\n\nconst X = Value.Default(T, null)                        // const 'X = null - non-enumerable\n\nconst Y = Value.Default(T, { })                         // const 'Y = { x: 0, y: 0 }\n\nconst Z = Value.Default(T, { x: 1 })                    // const 'Z = { x: 1, y: 0 }\n```\n\n\u003ca name='values-cast'\u003e\u003c/a\u003e\n\n### Cast\n\nUse the Cast function to upcast a value into a target type. This function will retain as much information as possible from the original value. The Cast function is intended to be used in data migration scenarios where existing values need to be upgraded to match a modified type.\n\n```typescript\nconst T = Type.Object({ x: Type.Number(), y: Type.Number() }, { additionalProperties: false })\n\nconst X = Value.Cast(T, null)                        // const X = { x: 0, y: 0 }\n\nconst Y = Value.Cast(T, { x: 1 })                    // const Y = { x: 1, y: 0 }\n\nconst Z = Value.Cast(T, { x: 1, y: 2, z: 3 })        // const Z = { x: 1, y: 2 }\n```\n\n\u003ca name='values-decode'\u003e\u003c/a\u003e\n\n### Decode\n\nUse the Decode function to decode a value from a type or throw if the value is invalid. The return value will infer as the decoded type. This function will run Transform codecs if available.\n\n```typescript\nconst A = Value.Decode(Type.String(), 'hello')        // const A = 'hello'\n\nconst B = Value.Decode(Type.String(), 42)             // throw\n```\n\u003ca name='values-decode'\u003e\u003c/a\u003e\n\n### Encode\n\nUse the Encode function to encode a value to a type or throw if the value is invalid. The return value will infer as the encoded type. This function will run Transform codecs if available.\n\n```typescript\nconst A = Value.Encode(Type.String(), 'hello')        // const A = 'hello'\n\nconst B = Value.Encode(Type.String(), 42)             // throw\n```\n\n\u003ca name='values-parse'\u003e\u003c/a\u003e\n\n### Parse\n\nUse the Parse function to parse a value. This function calls the `Clone` `Clean`, `Default`, `Convert`, `Assert` and `Decode` Value functions in this exact order to process a value.\n\n```typescript\nconst R = Value.Parse(Type.String(), 'hello')      // const R: string = \"hello\"\n\nconst E = Value.Parse(Type.String(), undefined)    // throws AssertError \n```\n\nYou can override the order in which functions are run, or omit functions entirely using the following.\n\n```typescript\n// Runs no functions.\n\nconst R = Value.Parse([], Type.String(), 12345)\n\n// Runs the Assert() function.\n\nconst E = Value.Parse(['Assert'], Type.String(), 12345)\n\n// Runs the Convert() function followed by the Assert() function.\n\nconst S = Value.Parse(['Convert', 'Assert'], Type.String(), 12345)\n```\n\n\u003ca name='values-equal'\u003e\u003c/a\u003e\n\n### Equal\n\nUse the Equal function to deeply check for value equality.\n\n```typescript\nconst R = Value.Equal(                               // const R = true\n  { x: 1, y: 2, z: 3 },\n  { x: 1, y: 2, z: 3 }\n)\n```\n\n\u003ca name='values-hash'\u003e\u003c/a\u003e\n\n### Hash\n\nUse the Hash function to create a [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash of a value.\n\n```typescript\nconst A = Value.Hash({ x: 1, y: 2, z: 3 })           // const A = 2910466848807138541n\n\nconst B = Value.Hash({ x: 1, y: 4, z: 3 })           // const B = 1418369778807423581n\n```\n\n\u003ca name='values-diff'\u003e\u003c/a\u003e\n\n### Diff\n\nUse the Diff function to generate a sequence of edits that will transform one value into another.\n\n```typescript\nconst E = Value.Diff(                                // const E = [\n  { x: 1, y: 2, z: 3 },                              //   { type: 'update', path: '/y', value: 4 },\n  { y: 4, z: 5, w: 6 }                               //   { type: 'update', path: '/z', value: 5 },\n)                                                    //   { type: 'insert', path: '/w', value: 6 },\n                                                     //   { type: 'delete', path: '/x' }\n                                                     // ]\n```\n\n\u003ca name='values-patch'\u003e\u003c/a\u003e\n\n### Patch\n\nUse the Patch function to apply a sequence of edits.\n\n```typescript\nconst A = { x: 1, y: 2 }\n\nconst B = { x: 3 }\n\nconst E = Value.Diff(A, B)                           // const E = [\n                                                     //   { type: 'update', path: '/x', value: 3 },\n                                                     //   { type: 'delete', path: '/y' }\n                                                     // ]\n\nconst C = Value.Patch\u003ctypeof B\u003e(A, E)                // const C = { x: 3 }\n```\n\n\u003ca name='values-errors'\u003e\u003c/a\u003e\n\n### Errors\n\nUse the Errors function to enumerate validation errors.\n\n```typescript\nconst T = Type.Object({ x: Type.Number(), y: Type.Number() })\n\nconst R = [...Value.Errors(T, { x: '42' })]          // const R = [{\n                                                     //   schema: { type: 'number' },\n                                                     //   path: '/x',\n                                                     //   value: '42',\n                                                     //   message: 'Expected number'\n                                                     // }, {\n                                                     //   schema: { type: 'number' },\n                                                     //   path: '/y',\n                                                     //   value: undefined,\n                                                     //   message: 'Expected number'\n                                                     // }]\n```\n\n\u003ca name='values-mutate'\u003e\u003c/a\u003e\n\n### Mutate\n\nUse the Mutate function to perform a deep mutable value assignment while retaining internal references.\n\n```typescript\nconst Y = { z: 1 }                                   // const Y = { z: 1 }\nconst X = { y: Y }                                   // const X = { y: { z: 1 } }\nconst A = { x: X }                                   // const A = { x: { y: { z: 1 } } }\n\nValue.Mutate(A, { x: { y: { z: 2 } } })              // A' = { x: { y: { z: 2 } } }\n\nconst R0 = A.x.y.z === 2                             // const R0 = true\nconst R1 = A.x.y === Y                               // const R1 = true\nconst R2 = A.x === X                                 // const R2 = true\n```\n\n\u003ca name='values-pointer'\u003e\u003c/a\u003e\n\n### Pointer\n\nUse ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) Json Pointers.\n\n```typescript\nimport { ValuePointer } from '@sinclair/typebox/value'\n\nconst A = { x: 0, y: 0, z: 0 }\n\nValuePointer.Set(A, '/x', 1)                         // A' = { x: 1, y: 0, z: 0 }\nValuePointer.Set(A, '/y', 1)                         // A' = { x: 1, y: 1, z: 0 }\nValuePointer.Set(A, '/z', 1)                         // A' = { x: 1, y: 1, z: 1 }\n```\n\n\n\n\u003ca name='syntax'\u003e\u003c/a\u003e\n\n## Syntax Types\n\nTypeBox provides experimental support for parsing TypeScript annotation syntax into TypeBox types.\n\nThis feature is provided via optional import.\n\n```typescript\nimport { Syntax } from '@sinclair/typebox/syntax'\n```\n\n\u003ca name='syntax-create'\u003e\u003c/a\u003e\n\n### Create\n\nUse the Syntax function to create TypeBox types from TypeScript syntax ([Example](https://www.typescriptlang.org/play/?moduleResolution=99\u0026module=199\u0026ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgChQkWIhTYYwBgWKly1OoxZtO3foMkSGEdDXgAVOAF4Uo3AAoABkhwAuOOgCuIPjygAaOFR3Lx8-AkcASjgY2Jj2djhjUwt3cwB5PgArHgYYAB4ECTiS0rLyisrYhNi3OHMAOW9fAOKq9o7OuBqY4PqmsKg2rpHR+MT8AD4JCS5eeut5LEUGfLmeCCJ6ybHKmvWFmyLdk86euDrQlv9h07uy876rv1v7t-GCIA))\n\n```typescript\nconst T = Syntax(`{ x: number, y: number }`)        // const T: TObject\u003c{\n                                                    //   x: TNumber,\n                                                    //   y: TNumber\n                                                    // }\u003e\n\ntype T = Static\u003ctypeof T\u003e                            // type T = {\n                                                     //   x: number,\n                                                     //   y: number\n                                                     // }\n```\n\n\u003ca name=\"syntax-parameters\"\u003e\u003c/a\u003e\n\n### Parameters\n\nSyntax types can be parameterized to receive exterior types ([Example](https://www.typescriptlang.org/play/?moduleResolution=99\u0026module=199\u0026ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgCgJDCOhrwAKnAC8KUbgAUAAyQ4AXHHQBXEHx5QANHFQHjp8wS0BKOK7ev27ODLmKDCgHk+ACseBhgAHgQJd1i4+ITEpLdPN304BQA5EzNLGOSCwqK4VNcbDOz7KHzi2rqPL3wAPikfeRQVNUxNJCV8Ky0ABSxYYCwmCIUm52LUtvhkfyDQ8Kia+o2C0rh0wLAYYFlxycrcpot1zav47fK9g6OJrJzzFuv3m8amoA))\n\n```typescript\nconst T = Syntax(`{ x: number, y: number }`)        // const T: TObject\u003c{\n                                                    //   x: TNumber,\n                                                    //   y: TNumber\n                                                    // }\u003e\n\nconst S = Syntax({ T }, `Partial\u003cT\u003e`)               // const S: TObject\u003c{\n                                                    //   x: TOptional\u003cTNumber\u003e,\n                                                    //   y: TOptional\u003cTNumber\u003e\n                                                    // }\u003e\n```\n\n\n\n\u003ca name=\"syntax-generics\"\u003e\u003c/a\u003e\n\n### Generics\n\nSyntax types support generic parameters in the following way ([Example](https://www.typescriptlang.org/play/?moduleResolution=99\u0026module=199\u0026ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgChQkWIhTYYwBgWKly1OoxZtO3foMkSGEdDXgA1HgxjQ4AXhSjcACgAGAHgAaAGjgBNXwAtAD45CTg4HAAuOB84cLhUGID4iIAvGMD4-FcASgkjEzM4ACEsOhpLa2gae0dMFyQqmygCX1cEBOi4Zuh3AEZfAAZh4O8EpJ6rFvcRuEG4IbGEjKnqqFnh337lnPyJLl5S8uBK6Zq65AUld0OeCCJjit6oGlCIiPZ2ODun05fag5Oh8QaCweCIZCoV8Pt0kN0FpM5qshm0ElCMZisSCYRFJvCYnNJgsUWjseSKeDcXBVgTFr4kb5Vv0COjKezsTD8EA))\n\n```typescript\nconst Vector = Syntax(`\u003cX, Y, Z\u003e { \n  x: X, \n  y: Y, \n  z: Z \n}`)\n\nconst BasisVectors = Syntax({ Vector }, `{\n  x: Vector\u003c1, 0, 0\u003e,\n  y: Vector\u003c0, 1, 0\u003e,\n  z: Vector\u003c0, 0, 1\u003e,\n}`)\n\ntype BasisVectors = Static\u003ctypeof BasisVectors\u003e     // type BasisVectors = {\n                                                    //   x: { x: 1, y: 0, z: 0 },\n                                                    //   y: { x: 0, y: 1, z: 0 },\n                                                    //   z: { x: 0, y: 0, z: 1 }\n                                                    // }\n```\n\n\u003ca name='syntax-options'\u003e\u003c/a\u003e\n\n### Options\n\nOptions can be passed via the last parameter.\n\n```typescript\nconst T = Syntax(`number`, { minimum: 42 })       // const T = {\n                                                  //   type: 'number',\n                                                  //   minimum: 42\n                                                  // }\n```\n\n\u003ca name='syntax-no-infer'\u003e\u003c/a\u003e\n\n### NoInfer\n\nSyntax parsing is an expensive type level operation and can impact on language service performance. Use the NoInfer function parse syntax at runtime only.\n\n```typescript\nimport { NoInfer } from '@sinclair/typebox/syntax'\n\nconst T = NoInfer(`number | string`)                // const T: TSchema = {\n                                                    //   anyOf: [\n                                                    //     { type: 'number' },\n                                                    //     { type: 'string' }\n                                                    //   ]\n                                                    // }\n```\n\n\u003ca name='typeregistry'\u003e\u003c/a\u003e\n\n## TypeRegistry\n\nThe TypeBox type system can be extended with additional types and formats using the TypeRegistry and FormatRegistry modules. These modules integrate deeply with TypeBox's internal type checking infrastructure and can be used to create application specific types, or register schematics for alternative specifications.\n\n\u003ca name='typeregistry-type'\u003e\u003c/a\u003e\n\n### TypeRegistry\n\nUse the TypeRegistry to register a type. The Kind must match the registered type name.\n\n```typescript\nimport { TSchema, Kind, TypeRegistry } from '@sinclair/typebox'\n\nTypeRegistry.Set('Foo', (schema, value) =\u003e value === 'foo')\n\nconst Foo = { [Kind]: 'Foo' } as TSchema \n\nconst A = Value.Check(Foo, 'foo')                    // const A = true\n\nconst B = Value.Check(Foo, 'bar')                    // const B = false\n```\n\n\u003ca name='typeregistry-format'\u003e\u003c/a\u003e\n\n### FormatRegistry\n\nUse the FormatRegistry to register a string format.\n\n```typescript\nimport { FormatRegistry } from '@sinclair/typebox'\n\nFormatRegistry.Set('foo', (value) =\u003e value === 'foo')\n\nconst T = Type.String({ format: 'foo' })\n\nconst A = Value.Check(T, 'foo')                      // const A = true\n\nconst B = Value.Check(T, 'bar')                      // const B = false\n```\n\n\u003ca name='typecheck'\u003e\u003c/a\u003e\n\n## TypeCheck\n\nTypeBox types target Json Schema Draft 7 and are compatible with any validator that supports this specification. TypeBox also provides a built-in type checking compiler designed specifically for TypeBox types that offers high performance compilation and value checking.\n\nThe following sections detail using Ajv and the TypeBox compiler infrastructure.\n\n\u003ca name='typ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fsinclair-typebox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fsinclair-typebox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fsinclair-typebox/lists"}