@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.
- package/package.json +1 -1
- package/readme.md +15 -14
package/package.json
CHANGED
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
|
|
1393
|
+
Generic types can be created using Argument types.
|
|
1394
1394
|
|
|
1395
1395
|
```typescript
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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>
|