UNPKG

lib0

Version:

isomorphic utility functions

655 lines • 24.9 kB
/** * @typedef {string|number|bigint|boolean|null|undefined|symbol} Primitive */ /** * @typedef {{ [k:string|number|symbol]: any }} AnyObject */ /** * @template T * @typedef {T extends Schema<infer X> ? X : T} Unwrap */ /** * @template T * @typedef {T extends Schema<infer X> ? X : T} TypeOf */ /** * @template {readonly unknown[]} T * @typedef {T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : [] } UnwrapArray */ /** * @template T * @typedef {T extends Schema<infer S> ? Schema<S> : never} CastToSchema */ /** * @template {unknown[]} Arr * @typedef {Arr extends [...unknown[], infer L] ? L : never} TupleLast */ /** * @template {unknown[]} Arr * @typedef {Arr extends [...infer Fs, unknown] ? Fs : never} TuplePop */ /** * @template {readonly unknown[]} T * @typedef {T extends [] * ? {} * : T extends [infer First] * ? First * : T extends [infer First, ...infer Rest] * ? First & Intersect<Rest> * : never * } Intersect */ export class ValidationError { /** * Reverse errors * @type {Array<{ path: string?, expected: string, has: string, message: string? }>} */ _rerrs: Array<{ path: string | null; expected: string; has: string; message: string | null; }>; /** * @param {string?} path * @param {string} expected * @param {string} has * @param {string?} message */ extend(path: string | null, expected: string, has: string, message?: string | null): void; toString(): string; } export function extendsShape(a: Schema<any>, b: Schema<any>): boolean; /** * @template T * @implements {equalityTraits.EqualityTrait} */ export class Schema<T> implements equalityTraits.EqualityTrait { /** * If true, the more things are added to the shape the more objects this schema will accept (e.g. * union). By default, the more objects are added, the the fewer objects this schema will accept. * @protected */ protected static _dilutes: boolean; get isSchema(): symbol; /** * Overwrite this when necessary. By default, we only check the `shape` property which every shape * should have. * @param {Schema<any>} other */ equals(other: Schema<any>): boolean; /** * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of * Schema. Validate will check the structure of the parameter and return true iff the instance * really is an instance of Schema. * * @param {T} o * @return {boolean} */ validate(o: T): boolean; /** * Similar to validate, but this method accepts untyped parameters. * * @param {any} _o * @param {ValidationError} [_err] * @return {_o is T} */ check(_o: any, _err?: ValidationError): _o is T; /** * @type {Schema<T?>} */ get nullable(): Schema<T | null>; /** * @type {$Optional<Schema<T>>} */ get optional(): $Optional<Schema<T>>; /** * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise. * Use this if you know that the type is of a specific type and you just want to convince the type * system. * * @template OO * @param {OO} o * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)} */ cast<OO>(o: OO): Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO, T>); /** * EXPECTO PATRONUM!! 🪄 * This method protects against type errors. * * "After all this time?" * "Always." - Snape, talking about type safety * * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed. * * Can be useful when defining lambdas: `s.lambda(s.$number, s.$number).expect((n) => n + 1)` * * @param {T} o * @return {T extends T ? T : never} */ expect(o: T): T extends T ? T : never; $type: Schema<Schema<any>>; /** * @param {object} other */ [equalityTraits.EqualityTraitSymbol](other: object): boolean; } /** * @extends {Schema<any>} */ export class $Type extends Schema<any> { /** * @param {string} name */ constructor(name: string); /** * @type {string} */ name: string; typeSymbol: symbol; /** * @param {any} o * @param {ValidationError} err * @return {o is any} */ check(o: any, err: ValidationError): o is any; $type: Schema<$Type>; } export function $type<T extends new (...args: any[]) => any>(uniqueName: string, TypeConstructor: T | { [K: string | number | symbol]: any; } | null): Schema<InstanceType<T>>; export const $$type: Schema<$Type>; /** * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} Constr * @typedef {Constr extends ((...args:any[]) => infer T) ? T : (Constr extends (new (...args:any[]) => any) ? InstanceType<Constr> : never)} Instance */ /** * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C * @extends {Schema<Instance<C>>} */ export class $ConstructedBy<C extends (new (...args: any[]) => any) | ((...args: any[]) => any)> extends Schema<Instance<C>> { /** * @param {C} c * @param {((o:Instance<C>)=>boolean)|null} check */ constructor(c: C, check: ((o: Instance<C>) => boolean) | null); shape: C; _c: ((o: Instance<C>) => boolean) | null; /** * @param {any} o * @param {ValidationError} [err] * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o */ check(o: any, err?: ValidationError): o is C extends ((...args: any[]) => infer T) ? T : (C extends (new (...args: any[]) => any) ? InstanceType<C> : never); } export function $constructedBy<C extends (new (...args: any[]) => any) | ((...args: any[]) => any)>(c: C, check?: ((o: Instance<C>) => boolean) | null): CastToSchema<$ConstructedBy<C>>; export const $$constructedBy: Schema<$ConstructedBy<(new (...args: any[]) => any) | ((...args: any[]) => any)>>; /** * Check custom properties on any object. You may want to overwrite the generated Schema<any>. * * @extends {Schema<any>} */ export class $Custom extends Schema<any> { /** * @param {(o:any,err?:ValidationError) => boolean} check */ constructor(check: (o: any, err?: ValidationError) => boolean); /** * @type {(o:any,err?:ValidationError) => boolean} */ shape: (o: any, err?: ValidationError) => boolean; } export function $custom(check: (o: any, err?: ValidationError) => boolean): Schema<any>; export const $$custom: Schema<$Custom>; /** * @template {Primitive} T * @extends {Schema<T>} */ export class $Literal<T extends Primitive> extends Schema<T> { /** * @param {Array<T>} literals */ constructor(literals: Array<T>); shape: T[]; } export function $literal<T extends Primitive[]>(...literals: T): CastToSchema<$Literal<T[number]>>; export const $$literal: Schema<$Literal<Primitive>>; export function $$literalWith<T extends Primitive[]>(...literals: T): Schema<CastToSchema<$Literal<T[number]>>>; /** * @template {Array<string|Schema<string|number>>} T * @extends {Schema<CastStringTemplateArgsToTemplate<T>>} */ export class $StringTemplate<T extends Array<string | Schema<string | number>>> extends Schema<CastStringTemplateArgsToTemplate<T>> { /** * @param {T} shape */ constructor(shape: T); shape: T; _r: RegExp; } export function $stringTemplate<T extends Array<string | Schema<string | number>>>(...literals: T): CastToSchema<$StringTemplate<T>>; export const $$stringTemplate: Schema<$StringTemplate<(string | Schema<string | number>)[]>>; /** * @template {Schema<any>} S * @extends Schema<Unwrap<S>|undefined> */ export class $Optional<S extends Schema<any>> extends Schema<Unwrap<S> | undefined> { /** * @param {S} shape */ constructor(shape: S); shape: S; } export const $$optional: Schema<$Optional<Schema<any>>>; /** * @type {Schema<never>} */ export const $never: Schema<never>; export const $$never: Schema<$Never>; /** * @template {{ [key: string|symbol|number]: Schema<any> }} S * @typedef {{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never }} $ObjectToType */ /** * @template {{[key:string|symbol|number]: Schema<any>}} S * @extends {Schema<$ObjectToType<S>>} */ export class $Object<S extends { [key: string | symbol | number]: Schema<any>; }> extends Schema<$ObjectToType<S>> { /** * @param {S} shape * @param {boolean} partial */ constructor(shape: S, partial?: boolean); /** * @type {S} */ shape: S; _isPartial: boolean; /** * @type {Schema<Partial<$ObjectToType<S>>>} */ get partial(): Schema<Partial<$ObjectToType<S>>>; /** * @param {any} o * @param {ValidationError} err * @return {o is $ObjectToType<S>} */ check(o: any, err: ValidationError): o is $ObjectToType<S>; } export function $object<S extends { [key: string | symbol | number]: any; }>(def: S): Schema<_ObjectDefToSchema<S>>; export const $$object: Schema<$Object<{ [key: string]: Schema<any>; [key: number]: Schema<any>; [key: symbol]: Schema<any>; }>>; export function $partial<S extends { [key: string | symbol | number]: any; }>(def: S): Schema<Partial<_ObjectDefToSchema<S>>>; /** * Matches plain objects only - `{}`-literals and `Object.create(null)` objects, not class * instances. The check is prototype-based, not `o.constructor === Object`, because a plain * object may declare an own property named "constructor". * * @type {Schema<{[key:string]: any}>} */ export const $objectAny: Schema<{ [key: string]: any; }>; /** * @template {Schema<string|number|symbol>} Keys * @template {Schema<any>} Values * @extends {Schema<{ [key in Unwrap<Keys>]: Unwrap<Values> }>} */ export class $Record<Keys extends Schema<string | number | symbol>, Values extends Schema<any>> extends Schema<{ [key in Unwrap<Keys>]: Unwrap<Values>; }> { /** * @param {Keys} keys * @param {Values} values */ constructor(keys: Keys, values: Values); shape: { keys: Keys; values: Values; }; /** * @param {any} o * @param {ValidationError} err * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }} */ check(o: any, err: ValidationError): o is { [key_1 in Unwrap<Keys>]: Unwrap<Values>; }; } export function $record<Keys extends Schema<string | number | symbol>, Values extends Schema<any>>(keys: Keys, values: Values): CastToSchema<$Record<Keys, Values>>; export const $$record: Schema<$Record<Schema<string | number | symbol>, Schema<any>>>; /** * @template {Schema<any>[]} S * @extends {Schema<{ [Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never }>} */ export class $Tuple<S extends Schema<any>[]> extends Schema<{ [Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never; }> { /** * @param {S} shape */ constructor(shape: S); shape: S; /** * @param {any} o * @param {ValidationError} err * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }} */ check(o: any, err: ValidationError): o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never; }; } export function $tuple<T extends Array<Schema<any>>>(...def: T): CastToSchema<$Tuple<T>>; export const $$tuple: Schema<$Tuple<Schema<any>[]>>; /** * @template {Schema<any>} S * @extends {Schema<Array<S extends Schema<infer T> ? T : never>>} */ export class $Array<S extends Schema<any>> extends Schema<(S extends Schema<infer T> ? T : never)[]> { /** * @param {Array<S>} v */ constructor(v: Array<S>); /** * @type {Schema<S extends Schema<infer T> ? T : never>} */ shape: Schema<S extends Schema<infer T_1> ? T_1 : never>; /** * @param {any} o * @param {ValidationError} [err] * @return {o is Array<S extends Schema<infer T> ? T : never>} o */ check(o: any, err?: ValidationError): o is Array<S extends Schema<infer T_1> ? T_1 : never>; } export function $array<T extends Array<Schema<any>>>(...def: T): Schema<Array<T extends Array<Schema<infer S>> ? S : never>>; export const $$array: Schema<$Array<Schema<any>>>; /** * @type {Schema<Array<any>>} */ export const $arrayAny: Schema<Array<any>>; /** * @template T * @extends {Schema<T>} */ export class $InstanceOf<T> extends Schema<T> { /** * @param {new (...args:any) => T} constructor * @param {((o:T) => boolean)|null} check */ constructor(constructor: new (...args: any) => T, check: ((o: T) => boolean) | null); shape: new (...args: any) => T; _c: ((o: T) => boolean) | null; /** * @param {any} o * @param {ValidationError} err * @return {o is T} */ check(o: any, err: ValidationError): o is T; } export function $instanceOf<T>(c: new (...args: any) => T, check?: ((o: T) => boolean) | null): Schema<T>; export const $$instanceOf: Schema<$InstanceOf<unknown>>; export const $$schema: Schema<Schema<any>>; /** * @template {Schema<any>[]} Args * @typedef {(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>} _LArgsToLambdaDef */ /** * @template {Array<Schema<any>>} Args * @extends {Schema<_LArgsToLambdaDef<Args>>} */ export class $Lambda<Args extends Array<Schema<any>>> extends Schema<_LArgsToLambdaDef<Args>> { /** * @param {Args} args */ constructor(args: Args); len: number; args: Schema<any[]>; res: Schema<any>; /** * @param {any} f * @param {ValidationError} err * @return {f is _LArgsToLambdaDef<Args>} */ check(f: any, err: ValidationError): f is _LArgsToLambdaDef<Args>; } export function $lambda<Args extends Schema<any>[]>(...args: Args): Schema<(...args: UnwrapArray<TuplePop<Args>>) => Unwrap<TupleLast<Args>>>; export const $$lambda: Schema<$Lambda<Schema<any>[]>>; /** * @type {Schema<Function>} */ export const $function: Schema<Function>; /** * @template {Array<Schema<any>>} T * @extends {Schema<Intersect<UnwrapArray<T>>>} */ export class $Intersection<T extends Array<Schema<any>>> extends Schema<Intersect<UnwrapArray<T>>> { /** * @param {T} v */ constructor(v: T); /** * @type {T} */ shape: T; } export function $intersect<T extends Schema<any>[]>(...def: T): CastToSchema<$Intersection<T>>; export const $$intersect: Schema<$Intersection<Schema<any>[]>>; /** * @template S * @extends {Schema<S>} */ export class $Union<S> extends Schema<S> { /** * @param {Array<Schema<S>>} v */ constructor(v: Array<Schema<S>>); shape: Schema<S>[]; } export function $union<T extends Array<any>>(...schemas: T): CastToSchema<$Union<ReadSchemaUnwrapped<T>>>; export const $$union: Schema<$Union<any>>; export function $<IN>(o: IN): Schema<import("./ts.js").TypeIsAny<IN, any, ReadSchemaUnwrapped<IN>>>; /** * Assert that a variable is of this specific type. * @type {<T>(o:any,schema:Schema<T>) => asserts o is T} */ export const assert: <T>(o: any, schema: Schema<T>) => asserts o is T; /** * Assert that a variable is of this specific type. * @type {<T>(o:any,schema:Schema<T>) => asserts o is T} */ export const assertNoCheck: <T>(o: any, schema: Schema<T>) => asserts o is T; /** * @type {Schema<any>} */ export const $any: Schema<any>; export const $$any: Schema<Schema<any>>; /** * @type {Schema<bigint>} */ export const $bigint: Schema<bigint>; export const $$bigint: Schema<Schema<bigint>>; /** * @type {Schema<symbol>} */ export const $symbol: Schema<symbol>; export const $$symbol: Schema<Schema<Symbol>>; /** * @type {Schema<number>} */ export const $number: Schema<number>; export const $$number: Schema<Schema<number>>; /** * A number without fractional component in the safe integer range (`Number.isSafeInteger`, * i.e. `|n| <= 2^53 - 1`). The unwrapped type is still `number` - JS has no separate integer type. * * The range restriction guarantees that every `$int` is exactly representable as a 64-bit * signed integer (`BigInt(n)` is lossless, databases can store it in an `int64` / `BIGINT` column). * Values like `1e20` are integers to `Number.isInteger`, but they are neither exact (every float * beyond 2^53 rounds to a multiple of a power of two) nor storable in 64 bits, so they are * rejected. Use `$number` for unbounded floats and `$bigint` for arbitrary-precision integers. * * @type {Schema<number>} */ export const $int: Schema<number>; export const $$int: Schema<Schema<number>>; /** * An unsigned integer: a `$int` that is `>= 0` (so `0 <= n <= 2^53 - 1`). The unwrapped type is * still `number` - JS has no separate integer type. * * Like `$int`, every `$uint` is exactly representable as a 64-bit integer (signed or unsigned). * See `$int` for why the range is restricted. * * @type {Schema<number>} */ export const $uint: Schema<number>; export const $$uint: Schema<Schema<number>>; /** * @type {Schema<string>} */ export const $string: Schema<string>; export const $$string: Schema<Schema<string>>; /** * @type {Schema<boolean>} */ export const $boolean: Schema<boolean>; export const $$boolean: Schema<Schema<boolean>>; /** * `$true`, `$false`, `$undefined` & `$null` are plain `$Literal`s (no own `$type`), so the generic * `$$literal` handling covers them in `random`, `coerce` & error messages. * * @type {Schema<true>} */ export const $true: Schema<true>; /** * @type {Schema<false>} */ export const $false: Schema<false>; /** * @type {Schema<undefined>} */ export const $undefined: Schema<undefined>; /** * @type {Schema<void>} */ export const $void: Schema<void>; export const $null: Schema<null>; export const $uint8Array: Schema<Uint8Array<ArrayBuffer>>; export const $$uint8Array: Schema<Schema<Uint8Array>>; export const $promise: Schema<Promise<unknown>>; export const $$promise: Schema<Schema<Uint8Array>>; /** * Primitive JavaScript types: immutable, non-object value that is stored and compared directly by * its value rather than by reference. * * @type {Schema<Primitive>} */ export const $primitive: Schema<Primitive>; /** * @typedef {JSON[]} JSONArray */ /** * @typedef {Primitive|JSONArray|{ [key:string]:JSON }} JSON */ /** * @type {Schema<null|number|string|boolean|JSON[]|{[key:string]:JSON}>} */ export const $json: Schema<null | number | string | boolean | JSON[] | { [key: string]: JSON; }>; /** * @todo move this to separate library * @template {any} [State=undefined] * @template {Pattern<any,any>} [Patterns=never] */ export class PatternMatcher<State extends unknown = undefined, Patterns extends Pattern<any, any> = never> { /** * @param {Schema<State>} [$state] */ constructor($state?: Schema<State>); /** * @type {Array<Patterns>} */ patterns: Array<Patterns>; $state: Schema<State> | undefined; /** * @template P * @template R * @param {P} pattern * @param {(o:NoInfer<ReadSchemaUnwrapped<P>>,s:State)=>R} handler * @return {PatternMatcher<State,Patterns|Pattern<ReadSchemaUnwrapped<P>,R>>} */ if<P, R>(pattern: P, handler: (o: NoInfer<ReadSchemaUnwrapped<P>>, s: State) => R): PatternMatcher<State, Patterns | Pattern<ReadSchemaUnwrapped<P>, R>>; /** * @template R * @param {(o:any,s:State)=>R} h */ else<R>(h: (o: any, s: State) => R): PatternMatcher<State, Patterns | Pattern<any, R>>; /** * @param {string} errorMessage */ error(errorMessage?: string): PatternMatcherFn<Patterns | Pattern<any, never>, State>; /** * @return {PatternMatcherFn<Patterns, State>} */ done(): PatternMatcherFn<Patterns, State>; } export function match<State = undefined>(state?: State): PatternMatcher<State extends undefined ? undefined : ReadSchemaUnwrapped<State>>; export function random<S>(gen: prng.PRNG, schema: S, fallback?: (gen: prng.PRNG, o: Schema<any>) => any): ReadSchemaUnwrapped<S>; export function coerce<S extends Schema<any>>(schema: S): (o: any) => { err: string; result: null; } | { err: null; result: Unwrap<S>; }; export type Primitive = string | number | bigint | boolean | null | undefined | symbol; export type AnyObject = { [k: string | number | symbol]: any; }; export type Unwrap<T> = T extends Schema<infer X> ? X : T; export type TypeOf<T> = T extends Schema<infer X> ? X : T; export type UnwrapArray<T extends readonly unknown[]> = T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : []; export type CastToSchema<T> = T extends Schema<infer S> ? Schema<S> : never; export type TupleLast<Arr extends unknown[]> = Arr extends [...unknown[], infer L] ? L : never; export type TuplePop<Arr extends unknown[]> = Arr extends [...infer Fs, unknown] ? Fs : never; export type Intersect<T extends readonly unknown[]> = T extends [] ? {} : T extends [infer First] ? First : T extends [infer First, ...infer Rest] ? First & Intersect<Rest> : never; export type Instance<Constr extends (new (...args: any[]) => any) | ((...args: any[]) => any)> = Constr extends ((...args: any[]) => infer T) ? T : (Constr extends (new (...args: any[]) => any) ? InstanceType<Constr> : never); export type CastStringTemplateArgsToTemplate<Ts extends Array<string | Schema<string | number>>> = Ts extends [] ? `` : (Ts extends [infer T] ? (Unwrap<T> extends (string | number) ? Unwrap<T> : never) : (Ts extends [infer T1, ...infer Rest] ? `${Unwrap<T1> extends (string | number) ? Unwrap<T1> : never}${Rest extends Array<string | Schema<string | number>> ? CastStringTemplateArgsToTemplate<Rest> : never}` : never)); export type $ObjectToType<S extends { [key: string | symbol | number]: Schema<any>; }> = { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never; } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never; }; export type _ObjectDefToSchema<S> = import("./ts.js").Prettify<{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never; } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never; }, 1>; export type _LArgsToLambdaDef<Args extends Schema<any>[]> = (...args: UnwrapArray<TuplePop<Args>>) => Unwrap<TupleLast<Args>>; export type ReadSchemaUnwrapped<IN extends unknown> = [Extract<IN, Schema<any>>, Extract<IN, string | number | boolean | null>, Extract<IN, new (...args: any[]) => any>, Extract<IN, any[]>, Extract<Exclude<IN, Schema<any> | string | number | boolean | null | (new (...args: any[]) => any) | any[]>, object>] extends [infer Schemas, infer Primitives, infer Constructors, infer Arrs, infer Obj] ? ((Schemas extends Schema<infer S> ? S : never) | Primitives | (Constructors extends new (...args: any[]) => any ? InstanceType<Constructors> : never) | (Arrs extends any[] ? { [K in keyof Arrs]: ReadSchemaUnwrapped<Arrs[K]>; }[keyof Arrs & number] : never) | (Obj extends object ? _ObjectDefToSchema<{ [K in keyof Obj]: Schema<ReadSchemaUnwrapped<Obj[K]>>; }> : never)) : never; export type ReadSchema<IN extends unknown> = Schema<ReadSchemaUnwrapped<IN>>; export type JSONArray = JSON[]; export type JSON = Primitive | JSONArray | { [key: string]: JSON; }; export type Pattern<In, Out> = { if: Schema<In>; h: (o: In, state?: any) => Out; }; export type PatternMatcherFn<Ps extends Pattern<any, any>, S> = import("./ts.js").UnionToIntersection<Ps extends Pattern<infer In, infer Out> ? [S] extends [undefined] ? (o: In) => Out : (o: In, state: S) => Out : never> & ([S] extends [undefined] ? (o: Ps extends Pattern<infer In, any> ? In : never) => (Ps extends Pattern<any, infer Out> ? Out : never) : (o: Ps extends Pattern<infer In, any> ? In : never, state: S) => (Ps extends Pattern<any, infer Out> ? Out : never)); /** * Carries the reason of a failed coercion out of the recursion. */ export type _CoerceCtx = { err: string; }; /** * A compiled coercer. Returns the coerced value, or `_failed` after writing the reason to * `ctx.err`. */ export type _Coercer = (o: any, path: string, ctx: _CoerceCtx) => any; import * as equalityTraits from './trait/equality.js'; /** * @extends Schema<never> */ declare class $Never extends Schema<never> { constructor(); } import * as prng from './prng.js'; export {}; //# sourceMappingURL=schema.d.ts.map