succulent
Version:
Powerful and easy runtime type checking
45 lines (44 loc) • 1.36 kB
TypeScript
import { Schema } from "../schema.js";
/**
* Checks if the value is a primitive `boolean`; `true` or `false`
* @example
* ```ts
* guard(true, $boolean); // ok
* guard(false, $boolean); // ok
* guard(1, $boolean); // will throw a `TypeError`
* ```
*/
export declare const $boolean: Schema<boolean>;
/**
* Checks if the value is `NaN` using `Number.isNaN`
* @remarks
* Unlike most other numbers, `NaN` cannot be used as a literal type, so this function
* can only narrow the type to `number`
* @internalRemarks
* There are a couple issues tracking this and other adjacent problems
* - <https://github.com/microsoft/TypeScript/issues/28682>
* - <https://github.com/microsoft/TypeScript/issues/32277>
* - <https://github.com/microsoft/TypeScript/issues/36964>
* @example
* ```ts
* guard(NaN, $NaN); // ok
* guard(0, $NaN); // throws a `TypeError` because `0` is not `NaN`
* ```
*/
export declare const $NaN: Schema<number>;
/**
* Alias for {@link $literal | `$literal(false)`}
*/
export declare const $false: Schema<false>;
/**
* Alias for {@link $literal | `$literal(true)`}
*/
export declare const $true: Schema<true>;
/**
* Alias for {@link $literal | `$literal(undefined)`}
*/
export declare const $undefined: Schema<undefined>;
/**
* Alias for {@link $literal | `$literal(null)`}
*/
export declare const $null: Schema<null>;