Skip to content

Commit

Permalink
Revision 0.34.19 (#1166)
Browse files Browse the repository at this point in the history
* Documentation

* Version
  • Loading branch information
sinclairzx81 authored Feb 12, 2025
1 parent 6b76fb9 commit de43700
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.34.18",
"version": "0.34.19",
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down
29 changes: 15 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1390,25 +1390,26 @@ const S = Syntax({ T }, `{ x: T, y: T, z: T }`) // const S: TObject<{
### Generics
Generic types can be created by passing Argument types as parameters.
Generic types can be created using Argument types.
```typescript
// Generic Vector Type

const Vector = Syntax({ // type Vector<X, Y, Z> = {
X: Type.Argument(0), // x: X
Y: Type.Argument(1), // y: Y,
Z: Type.Argument(2) // z: Z
}, // }
`{
x: X,
y: Y,
z: Z
const Vector = Syntax(`{
x: Argument<0>,
y: Argument<1>,
z: Argument<2>
}`)

// Instanced Vector Type
const Basis = Syntax({ Vector }, `{
x: Vector<1, 0, 0>,
y: Vector<0, 1, 0>,
z: Vector<0, 0, 1>,
}`)

const Up = Syntax({ Vector }, `Vector<0, 1, 0>`) // type Up = Vector<0, 1, 0>
type Basis = Static<typeof Basis> // type Basis = {
// x: { x: 1, y: 0, z: 0 },
// y: { x: 0, y: 1, z: 0 },
// z: { x: 0, y: 0, z: 1 }
// }
```
<a name='typeregistry'></a>
Expand Down

0 comments on commit de43700

Please sign in to comment.