TypeBox is a JSON schema type builder with static type resolution for TypeScript. Below is an usage example:
import Type from 'typebox'const T = Type.Object({ // const T = { x: Type.Number(), // type: 'object', y: Type.Number(), // properties: { z: Type.Number() // x: { type: 'number' },}) // y: { type: 'number' }, // z: { type: 'number' } // }, // required: ['x', 'y', 'z'] // }type T = Type.Static<typeof T> // type T = { // x: number, // y: number, // z: number // }
TypeBox is a runtime type system 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 system that can be statically checked by TypeScript and validated at runtime using standard JSON Schema.
This 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.
I found TypeBox references in pi-mono codebase. pi-mono is an AI agent toolkit providing coding agent CLI, unified LLM API, TUI & web UI libraries, Slack bot, vLLM pods