import { Cast, Convert, TCastAll, CastSettings } from "./internal.js"; import { Collection, Nothing, PrimitiveValue, SimpleType, SimpleTypeOf, Struct } from "./types.js"; declare type TGuardEvery[]> = A extends Array ? ((g: T) => void) extends ((g: Guard) => void) ? I : unknown : never; declare abstract class Was { protected type: U | undefined; private constructor(); } declare type SubtypeOf = unknown extends T ? T & U : T extends never ? T & U : T extends null ? T & U : T extends undefined ? T & U : T & U & Was; export declare type TGuardMap = T extends SimpleType ? SimpleTypeOf : T extends Guard ? R : T extends { [k in keyof T]: any; } ? { [k in keyof T]: TGuardMap; } : unknown; export declare class GuardError extends Error { constructor(message: string); } export declare class Guard extends Cast { protected readonly _guard: (input: unknown, settings: CastSettings) => input is T; protected readonly _assert: (input: unknown, settings: CastSettings) => void; constructor(_check: (input: unknown, settings: CastSettings) => input is T); static readonly isUnknown: Guard; static readonly isNever: Guard; static readonly isAny: Guard; static lazy(fun: (s: CastSettings) => Guard): Guard; guard(input: U): input is SubtypeOf; guard(input: U, settings: CastSettings): input is SubtypeOf; assert(input: U): void; assert(input: U, settings: CastSettings): void; config(config: Partial): Guard; and(right: Guard): Guard; and(right: (t: T, s: CastSettings) => t is T & R): Guard; or(right: Guard): Guard; or(right: Convert): Convert; or(right: Cast): Cast; if(condition: (input: T) => unknown): Guard; /** * Intersects a list of guards by combining them with the `and` operator. * @param guards An array of guards. * @returns The intersection of the given guards. */ static every[]>(...guards: T): Guard>; static isConst(value: T): Guard; static isClass(cls: new (...args: any[]) => T): Guard; static isEnum(options: T): Guard; static get isPrimitiveValue(): Guard; static get isNothing(): Guard; static get isObject(): Guard; static get isPrimitive(): Guard; static get isSomething(): Guard; static get isString(): Guard; static get isNumber(): Guard; static get isBigInt(): Guard; static get isBoolean(): Guard; static get isSymbol(): Guard; static get isFinite(): Guard; static get isInteger(): Guard; static get isSafeInteger(): Guard; static get isCollection(): Guard; static get isStruct(): Guard; static get isArray(): Guard>; static get isFunction(): Guard; static isInstanceOf(cls: new (...args: any[]) => T): Guard; static isCollectionOf(guard: Guard): Guard>; static isArrayOf(guard: Guard): Guard; static isStructOf(guard: Guard): Guard>; /** * Given an object or tuple of guards, it produces a guard that guards for an object or tuple that has the same shape as the given guards. * @param casts an object or tuple of guards * @returns a guard that guards for an object or tuple matching the shape of the given guards */ static isCollectionLike>(guards: T): Guard>; /** * Creates a `Guard` based on a sample value. * @param alt a sample value * @returns a `Guard` based on the given sample value */ static is(alt: T): Guard>; } export {};