TypeMap
Unified Syntax Frontend and Type Remapping System for TypeBox, Valibot and Zod
[](https://badge.fury.io/js/%40sinclair%2Ftypebox-adapter)
[](https://www.npmjs.com/package/%40sinclair%2Ftypebox-adapter)
[](https://github.com/sinclairzx81/typebox-adapter/actions/workflows/build.yml)
[](https://opensource.org/licenses/MIT)
## Install
```bash
$ npm install @sinclair/typemap --save
```
## Example
Use syntax to construct types for TypeBox, Valibot and Zod ...
```typescript
import { TypeBox, Zod, Valibot } from '@sinclair/typemap'
// const T: TObject<{ ... }>
const T = TypeBox(`{
x: number,
y: number,
z: number
}`)
// const V: ObjectSchema<{ ... }>
const V = Valibot(`{
x: number,
y: number,
z: number
}`)
// const Z: ZodObject<{ ... }>
const Z = Zod(`{
x: number,
y: number,
z: number
}`)
```
... or structurally remap types from one library to another
```typescript
import { TypeBox, Valibot, Zod } from '@sinclair/typemap'
// Syntax > Zod > Valibot > TypeBox
const T = TypeBox(Valibot(Zod(`{
x: number,
y: number,
z: number
}`)))
```
... or compile types for high performance runtime type checking
```typescript
import { Compile } from '@sinclair/typemap'
import z from 'zod'
const T = z.object({ // const T: z.ZodObject<{
x: z.number(), // x: z.ZodNumber,
y: z.number(), // y: z.ZodNumber,
z: z.number(), // z: z.ZodNumber,
}) // }>
const C = Compile(T) // const C: Validator