import { Brand } from "@tsplus/runtime/Brand"; import { Check, TypeLevel } from "@tsplus/stdlib/type-level"; import { Maybe } from "@tsplus/stdlib/data/Maybe/definition"; import { Chunk } from "@tsplus/stdlib/collections/Chunk/definition"; import { List } from "@tsplus/stdlib/collections/List/definition"; import { SortedSet } from "@tsplus/stdlib/collections/SortedSet/definition"; import { ImmutableArray } from "@tsplus/stdlib/collections/ImmutableArray/definition"; import { NonEmptyImmutableArray } from "@tsplus/stdlib/collections/NonEmptyImmutableArray/definition"; import { Either } from "@tsplus/stdlib/data/Either/definition"; /** * A Guard is a type representing the ability to identify when a value is of type A at runtime * * @tsplus type Guard * @tsplus derive nominal */ export interface Guard { readonly is: (u: unknown) => u is A; } /** * @tsplus type GuardOps */ export interface GuardOps { (f: (u: unknown) => u is A): Guard; } /** * Creates a new Guard */ export declare const Guard: GuardOps; /** * Guard for `true` * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const _true: Guard; /** * Guard for `false` * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const _false: Guard; /** * Guard for a boolean * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const boolean: Guard; /** * Guard for a number * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const number: Guard; /** * Guard for null * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const _null: Guard; /** * Guard for a string * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const string: Guard; /** * Guard for a Date * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const date: Guard; /** * Guard for an object shaped like { _tag: string } * @tsplus implicit * @tsplus location "@tsplus/runtime/Guard" */ export declare const taggedObject: Guard<{ _tag: string; }>; /** * @tsplus derive Guard lazy * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveLazy(fn: (_: Guard) => Guard): Guard; /** * @tsplus derive Guard<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveNamed>(...[base]: Check> extends Check.False ? [ base: Guard> ] : never): Guard; /** * @tsplus derive Guard<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveValidation>(...[base, brands]: Check> extends Check.True ? [ base: Guard>, brands: { [k in (keyof A[Brand.valid]) & string]: Brand.Validation; } ] : never): Guard; /** * @tsplus derive Guard<_> 20 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveLiteral(...[value]: Check & Check.Not>> extends Check.True ? [value: A] : never): Guard; /** * @tsplus derive Guard[Maybe]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveOption>(...[element]: [A] extends [Maybe] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[Chunk]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveChunk>(...[element]: [A] extends [Chunk] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[List]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveList>(...[element]: [A] extends [List] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[SortedSet]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveSortedSet>(...[element]: [A] extends [SortedSet] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[NonEmptyImmutableArray]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveNonEmptyImmutableArray>(...[element]: [A] extends [NonEmptyImmutableArray] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[ImmutableArray]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveImmutableArray>(...[element]: [A] extends [ImmutableArray] ? [element: Guard<_A>] : never): Guard; /** * @tsplus derive Guard[Array]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveArray>(...[element]: [A] extends [Array] ? Check>> extends Check.True ? [element: Guard<_A>] : never : never): Guard; /** * @tsplus derive Guard[Either]<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveEither>(...[left, right]: [A] extends [Either] ? [left: Guard<_E>, right: Guard<_A>] : never): Guard; /** * @tsplus derive Guard<_> 10 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveEmptyRecord(..._: Check> extends Check.True ? [] : never): Guard; /** * @tsplus derive Guard<_> 20 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveStruct>(...[requiredFields, optionalFields]: Check> extends Check.True ? [ ...[ requiredFields: { [k in TypeLevel.RequiredKeys]: Guard; } ], ...([TypeLevel.OptionalKeys] extends [never] ? [] : [ optionalFields: { [k in TypeLevel.OptionalKeys]: Guard>; } ]) ] : never): Guard; /** * @tsplus derive Guard<_> 15 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveDictionary>(...[valueGuard]: Check> extends Check.True ? [value: Guard] : never): Guard; /** * @tsplus derive Guard<_> 15 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveRecord>(...[value, requiredKeys]: Check> extends Check.True ? [ value: Guard, requiredKeys: { [k in keyof A]: 0; } ] : never): Guard; /** * @tsplus derive Guard<_> 20 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveTagged(...[elements]: Check> extends Check.True ? [ elements: { [k in A["_tag"]]: Guard>; } ] : never): Guard; /** * @tsplus derive Guard<|> 30 * @tsplus location "@tsplus/runtime/Guard" */ export declare function deriveUnion(...elements: { [k in keyof A]: Guard; }): Guard; /** * @tsplus fluent Guard asserts * @tsplus location "@tsplus/runtime/Guard" */ export declare function asserts(self: Guard, u: unknown): asserts u is A; //# sourceMappingURL=Guard.d.ts.map