Decompose monolithic readme into docs/ directory structure
This commit is contained in:
37
docs/type-map.md
Normal file
37
docs/type-map.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[Overview](./overview.md) | [Installation](./installation.md) | [Usage](./usage.md) | [Types](./types/) | [Values](./values/) | [Syntax](./syntax/) | [TypeRegistry](./type-registry.md) | [TypeCheck](./type-check.md)
|
||||
|
||||
# TypeMap
|
||||
|
||||
TypeBox offers an external package for bidirectional mapping between TypeBox, Valibot, and Zod type libraries. It also includes syntax parsing support for Valibot and Zod and supports the Standard Schema specification. For more details on TypeMap, refer to the project repository.
|
||||
|
||||
[TypeMap Repository](https://git.alk.dev/alkdev/typebox)
|
||||
|
||||
## Usage
|
||||
|
||||
TypeMap needs to be installed separately
|
||||
|
||||
```bash
|
||||
$ npm install @sinclair/typemap
|
||||
```
|
||||
|
||||
Once installed it offers advanced structural remapping between various runtime type libraries ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgFQJ5gKYCEIA8A0cAyqgHYwCGBcAWhACZwC+cAZlBCHAOQACAzsFIBjADYVgUAPQx0GEBTDcAUMuERS-eMjgBeFHJy4AFAAMkuAFxxSAVxAAjDFEKprdx88IAvd-adQzKYAlHBwUlJw6pra1sgA8g4AVhjCMAA8CMphObl5+QWFRcW5ETlWKABy-s4A3NkljU3NBWVhblU1UPUtvX3FbXC+nZ7dDf0TE2VMAHyq0VrEesRklCbIoS1lC-BE1twWfqOuRwE+p87MKmoaiwBKy3T0xkTBAHRgFFD8GMZ2oqJNnltrd4HdrFlJltImEKh4Aj0oU1Bh14XVxkiBjChhcxpjGtMwkA))
|
||||
|
||||
```typescript
|
||||
import { TypeBox, Syntax, Zod } from "@sinclair/typemap";
|
||||
|
||||
const T = TypeBox(`{ x: number, y: number, z: number }`); // const T: TObject<{
|
||||
// x: TNumber;
|
||||
// y: TNumber;
|
||||
// z: TNumber;
|
||||
// }>
|
||||
|
||||
const S = Syntax(T); // const S: '{ x: number, y: number, z: number }'
|
||||
|
||||
const R = Zod(S).parse(null); // const R: {
|
||||
// x: number;
|
||||
// y: number;
|
||||
// z: number;
|
||||
// }
|
||||
```
|
||||
|
||||
Back to [Home](../readme.md)
|
||||
Reference in New Issue
Block a user