Update Example

This commit is contained in:
sinclair
2023-02-16 19:52:28 +09:00
parent 5515fb681f
commit ac0a3e2963
+26 -1
View File
@@ -8,8 +8,11 @@ import { Custom } from '@sinclair/typebox/custom'
import { Value, ValuePointer } from '@sinclair/typebox/value'
import { Type, Kind, Static, TSchema } from '@sinclair/typebox'
// -----------------------------------------------------------
// Create: Type
// -----------------------------------------------------------
const T = Type.Object({
/** It's a X */
x: Type.Number(),
y: Type.Number(),
z: Type.Number(),
@@ -18,3 +21,25 @@ const T = Type.Object({
type T = Static<typeof T>
console.log(T)
// -----------------------------------------------------------
// Create: Value
// -----------------------------------------------------------
const V = Value.Create(T)
console.log(V)
// -----------------------------------------------------------
// Compile: Type
// -----------------------------------------------------------
const C = TypeCompiler.Compile(T)
console.log(C.Code())
// -----------------------------------------------------------
// Check: Value
// -----------------------------------------------------------
console.log(C.Check(V))