1.2 KiB
1.2 KiB
Home | Installation | Usage | Types | Values | Syntax | TypeRegistry | TypeCheck
Generics
Syntax types support generic parameters in the following way (Example)
const Vector = Syntax(`<X, Y, Z> {
x: X,
y: Y,
z: Z
}`);
const BasisVectors = Syntax(
{ Vector },
`{
x: Vector<1, 0, 0>,
y: Vector<0, 1, 0>,
z: Vector<0, 0, 1>,
}`
);
type BasisVectors = Static<typeof BasisVectors>; // type BasisVectors = {
// x: { x: 1, y: 0, z: 0 },
// y: { x: 0, y: 1, z: 0 },
// z: { x: 0, y: 0, z: 1 }
// }
Back to Home