@sinclair/typebox 0.34.18 → 0.34.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +15 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.34.18",
3
+ "version": "0.34.19",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/readme.md CHANGED
@@ -1390,25 +1390,26 @@ const S = Syntax({ T }, `{ x: T, y: T, z: T }`) // const S: TObject<{
1390
1390
 
1391
1391
  ### Generics
1392
1392
 
1393
- Generic types can be created by passing Argument types as parameters.
1393
+ Generic types can be created using Argument types.
1394
1394
 
1395
1395
  ```typescript
1396
- // Generic Vector Type
1397
-
1398
- const Vector = Syntax({ // type Vector<X, Y, Z> = {
1399
- X: Type.Argument(0), // x: X
1400
- Y: Type.Argument(1), // y: Y,
1401
- Z: Type.Argument(2) // z: Z
1402
- }, // }
1403
- `{
1404
- x: X,
1405
- y: Y,
1406
- z: Z
1396
+ const Vector = Syntax(`{
1397
+ x: Argument<0>,
1398
+ y: Argument<1>,
1399
+ z: Argument<2>
1407
1400
  }`)
1408
1401
 
1409
- // Instanced Vector Type
1402
+ const Basis = Syntax({ Vector }, `{
1403
+ x: Vector<1, 0, 0>,
1404
+ y: Vector<0, 1, 0>,
1405
+ z: Vector<0, 0, 1>,
1406
+ }`)
1410
1407
 
1411
- const Up = Syntax({ Vector }, `Vector<0, 1, 0>`) // type Up = Vector<0, 1, 0>
1408
+ type Basis = Static<typeof Basis> // type Basis = {
1409
+ // x: { x: 1, y: 0, z: 0 },
1410
+ // y: { x: 0, y: 1, z: 0 },
1411
+ // z: { x: 0, y: 0, z: 1 }
1412
+ // }
1412
1413
  ```
1413
1414
 
1414
1415
  <a name='typeregistry'></a>