import { type LiteralSchema, Schema, type SchemaBase } from "../schema.js"; export declare function $instanceof(t: T): Schema; /** * @internalRemarks * Like `instanceof`, but for constructors that might not actually be defined, such as * `Blob` or `File`. If the type `T` is not available in the current environment, the * returned schema will be an alias of `$never`. */ export declare function $tryinstanceof(mapT: () => T): Schema; /** * Alias for $instanceof, i.e. checks if a value is "a"/an `T` */ export declare const a: typeof $instanceof; /** * Checks for equality with `Object.is`. * @example * ```ts * guard(1, $literal(1)); // ok * guard(2, $literal(1)); // throws a `TypeError` because `1 !== 2` * guard("hello", $literal("hello")); // ok * guard("hey", $literal("hello")); // throws a `TypeError` because `"hey" !== "hello"` * ``` */ export declare function $literal(t: T): Schema; export type nullish = undefined | null; /** * Matches `null` or `undefined`. * @example * ```ts * guard(undefined, $nullish); // ok * guard(null, $nullish); // ok * guard(0, $nullish); // throws a `TypeError` because `0` is not `null` or `undefined` * ``` */ export declare const $nullish: Schema<((x: unknown) => x is nullish) | null | undefined>; /** * @internalRemarks * Notably missing is (typeof NaN), which can't be included because it just * evaluates to `number`, and the vast majority of numbers are not falsy */ export type falsy = false | 0 | 0n | "" | nullish; /** * @example * ```ts */ export declare const $falsy: Schema; /** * Alias for `union($T, undefined)` (with a prettier display name). * @example * ```ts * guard(undefined, $optional($string)); // ok * guard("hello, computer!", $optional($string)); // ok * guard(0, $optional($string)); // throws a `TypeError` because `0` is not a string * ``` */ export declare function $optional(base: SchemaBase): Schema; /** * Alias for `union($T, null, undefined)` (with a prettier display name). * @example * ```ts * guard(undefined, $optional($string)); // ok * guard("hello, computer!", $optional($string)); // ok * guard(0, $optional($string)); // throws a `TypeError` because `0` is not a string * ``` */ export declare function $maybe(base: SchemaBase): Schema; /** * As the name suggests, any value passed will be valid, even values you might * really not expect, like functions. * @remarks * If you think you want to use this, similarly to in actual TypeScript, you * should probably use `$unknown` instead. * @example * ```ts * guard(undefined, $any); // ok * guard(null, $any); // ok * guard(1, $any); // ok * guard("hello", $any); // ok * guard({}, $any); // ok * guard([], $any); // ok * guard(Symbol(), $any); // ok * guard(() => {}, $any); // ok * guard(class {}, $any); // ok * guard(new Date(), $any); // ok * guard(/friend/, $any); // ok * // ...you get the point * ``` */ export declare const $any: Schema; /** * Useful for situations where you want to say "there's a value here", but you * don't know the type or want to resolve/check the value later. * @remarks * Probably shouldn't be used very frequently, but occasionally useful for * stuff like `$Array($unknown)` or just specifying that an object should have a * key, without needing to specify the whole type. Basically the same kind of * cases you might want to use it for in TypeScript. * @example * ```ts * guard(undefined, $unknown); // ok * guard(null, $unknown); // ok * guard(1, $unknown); // ok * guard("hello", $unknown); // ok * guard({}, $unknown); // ok * guard([], $unknown); // ok * guard(Symbol(), $unknown); // ok * guard(() => {}, $unknown); // ok * guard(class {}, $unknown); // ok * guard(new Date(), $unknown); // ok * guard(/friend/, $unknown); // ok * // ...you get the point * ``` */ export declare const $unknown: Schema; /** * The opposite of `$any`, this schema will never match anything. * @remarks * Mostly useful for tests to convey that something should never match. * @example * ```ts * guard(undefined, $never); // throws a `TypeError` * guard(null, $never); // throws a `TypeError` * guard(1, $never); // throws a `TypeError` * guard("hello", $never); // throws a `TypeError` * guard({}, $never); // throws a `TypeError` * guard([], $never); // throws a `TypeError` * guard(Symbol(), $never); // throws a `TypeError` * guard(() => {}, $never); // throws a `TypeError` * guard(class {}, $never); // throws a `TypeError` * guard(new Date(), $never); // throws a `TypeError` * guard(/friend/, $never); // throws a `TypeError` * // ...you get the point * ``` */ export declare const $never: Schema; export declare const $Blob: Schema; export declare const $Buffer: Schema; export declare const $Date: Schema; export declare const $File: Schema; export declare const $Error: Schema; export declare const $RegExp: Schema; export declare const $Request: Schema; export declare const $Response: Schema; export declare const $URL: Schema; /** * @remarks * One subtle use case for for `$ArrayBuffer` is to ensure that you *actually* have an * `ArrayBuffer` object, and not a `Uint8Array` or some other view. A little known fact is * that TypeScript will happily let you use a typed array in place of an `ArrayBuffer`, * which is almost never what you want. * @example * ```ts * function doSomeMagic(buffer: ArrayBuffer) { * guard(buffer, $ArrayBuffer); * // now you can *actually* be sure that `buffer` is an `ArrayBuffer` * } * ``` */ export declare const $ArrayBuffer: Schema; /** * `ArrayBufferView`s are anything that's backed by an `ArrayBuffer`, like a `Uint8Array` * or any other typed array. * @example * ```ts * guard(new Uint8Array(), $ArrayBufferView); // ok * guard(new ArrayBuffer(), $ArrayBufferView); // throws a `TypeError`, `ArrayBuffer` is not an `ArrayBufferView` * ``` */ export declare const $ArrayBufferView: Schema>; export declare const $Int8Array: Schema>; export declare const $Int16Array: Schema>; export declare const $Int32Array: Schema>; export declare const $BigInt64Array: Schema>; export declare const $Uint8Array: Schema>; export declare const $Uint8ClampedArray: Schema>; export declare const $Uint16Array: Schema>; export declare const $Uint32Array: Schema>; export declare const $BigUint64Array: Schema>; export declare const $Float32Array: Schema>; export declare const $Float64Array: Schema>;