Files
typebox/example/index.ts
glm-5.1 bd758c2342 Fork from @sinclair/typebox 0.34.49 as @alkdev/typebox
- Rename package from @sinclair/typebox to @alkdev/typebox
- Update author, repository, and homepage to alkdev
- Remove GitHub workflows, .vscode config, and branding assets
- Update all source, test, example, changelog, and task imports
- Update tsconfig.json path mappings
- Clean up readme header (remove upstream badges/branding)
2026-04-23 13:22:31 +00:00

50 lines
1.3 KiB
TypeScript

import { TypeSystem } from '@alkdev/typebox/system'
import { TypeCompiler } from '@alkdev/typebox/compiler'
import { Value, ValuePointer } from '@alkdev/typebox/value'
import { Type, TypeGuard, Kind, Static, TSchema } from '@alkdev/typebox'
import { Syntax } from '@alkdev/typebox/syntax'
// -----------------------------------------------------------
// Create: Type
// -----------------------------------------------------------
const T = Type.Object({
x: Type.Number(),
y: Type.Number(),
z: Type.Number(),
})
type T = Static<typeof T>
console.log(T)
// -----------------------------------------------------------
// Syntax: Type
// -----------------------------------------------------------
const S = Syntax({ T }, `{ x: T, y: T, z: T }`)
type S = Static<typeof S>
// -----------------------------------------------------------
// 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))