/** * Collection of assert functions that not only throw errors at runtime, but * also work as assertions in TypeScript. Use this module by importing from * `@sirpepe/shed/assert`. */ import type { Primitive } from "./types"; /** * Throws an exception when the first argument is null or undefined. The second * argument can be used to customize the exception, but is entirely optional. * This function works as a type assertion in TypeScript and is the inverse of * `assertIsNot()`. * * Example: * * ```typescript * assertIs(42, "Oops"); // nothing happens * assertIs(null, , "Oops"); // Error: "Oops" * ``` */ export declare function assertIs(x: T | undefined | null, msg?: string): asserts x is T; /** * Throws an exception when the first argument is not null or undefined. The * second argument can be used to customize the exception, but is entirely * optional. This function works as a type assertion in TypeScript and is the * inverse of `assertIs()`. * * Example: * * ```typescript * assertIsNot(null, , "Oops"); // nothing happens * assertIsNot(42, "Oops"); // Error: "Oops" * ``` */ export declare function assertIsNot(x: T | undefined | null, msg?: string): asserts x is undefined | null; /** * Throws an exception when the first argument is not not a primitive. The * second argument can be used to customize the exception, but is entirely * optional. This function works as a type assertion in TypeScript. * * Example: * * ```typescript * assertIsPrimitive(null, , "Oops"); // nothing happens * assertIsPrimitive([42], "Oops"); // TypeError: "Oops" * ``` */ export declare function assertIsPrimitive(x: any, msg?: string): asserts x is Primitive;