Decompose monolithic readme into docs/ directory structure
This commit is contained in:
29
docs/syntax/create.md
Normal file
29
docs/syntax/create.md
Normal file
@@ -0,0 +1,29 @@
|
||||
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | [Types](../types/) | [Values](../values/) | **Syntax** | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
|
||||
|
||||
# Create
|
||||
|
||||
TypeBox provides experimental support for parsing TypeScript annotation syntax into TypeBox types.
|
||||
|
||||
This feature is provided via optional import.
|
||||
|
||||
```typescript
|
||||
import { Syntax } from "@alkdev/typebox/syntax";
|
||||
```
|
||||
|
||||
## Create
|
||||
|
||||
Use the Syntax function to create TypeBox types from TypeScript syntax ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgChQkWIhTYYwBgWKly1OoxZtO3foMkSGEdDXgAVOAF4Uo3AAoABkhwAuOOgCuIPjygAaOFR3Lx8-AkcASjgY2Jj2djhjUwt3cwB5PgArHgYYAB4ECTiS0rLyisrYhNi3OHMAOW9fAOKq9o7OuBqY4PqmsKg2rpHR+MT8AD4JCS5eeut5LEUGfLmeCCJ6ybHKmvWFmyLdk86euDrQlv9h07uy876rv1v7t-GCIA))
|
||||
|
||||
```typescript
|
||||
const T = Syntax(`{ x: number, y: number }`); // const T: TObject<{
|
||||
// x: TNumber,
|
||||
// y: TNumber
|
||||
// }>
|
||||
|
||||
type T = Static<typeof T>; // type T = {
|
||||
// x: number,
|
||||
// y: number
|
||||
// }
|
||||
```
|
||||
|
||||
Back to [Home](../../readme.md)
|
||||
Reference in New Issue
Block a user