Creates a LazyTypeGuard that evaluates the generator function only when needed.
LazyTypeGuard
This is useful for:
The type to guard
A function that returns the actual type guard when called
A type guard for T
T
const isPeople = isLazy(() => isPerson).array(); Copy
const isPeople = isLazy(() => isPerson).array();
type Tree = { value: number; left?: Tree; right?: Tree };const isTree: TypeGuard<Tree> = isType<Tree>({ value: isNumber, left: isLazy(() => isTree).optional(), right: isLazy(() => isTree).optional(),}); Copy
type Tree = { value: number; left?: Tree; right?: Tree };const isTree: TypeGuard<Tree> = isType<Tree>({ value: isNumber, left: isLazy(() => isTree).optional(), right: isLazy(() => isTree).optional(),});
Creates a
LazyTypeGuardthat evaluates the generator function only when needed.This is useful for: