Search


Search something to see results

lazy

Type Parameters

  • T

Parameters

  • getSchema: Object

Returns Schema<T>

type Tree = { left: Leaf | Tree, right: Leaf | Tree }
type Leaf = string;

const tree = x.object<Tree>({
get left(): x.Schema<Leaf | Tree> {
return x.union(x.string, tree)
},
get right(): x.Schema<Leaf | Tree> {
return x.union(x.string, tree)
},
})
type Tree = { left: Tree | Leaf, right: Tree | Leaf }
type Leaf = string;

const tree: x.ObjectSchema<Tree> = x.object({
left: x.lazy(() => x.union(x.string, tree)),
right: x.lazy(() => x.union(x.string, tree)),
})