UNPKG

@leancodepl/utils

Version:

Common utility functions and React hooks for web applications

18 lines (17 loc) 652 B
/** * Asserts that a value is not null. Throws an error if the value is null. * This is a type assertion function that narrows the type to exclude null. * * @template T - The type of the value being checked * @param value - The value to check for null * @param message - Optional error message to use if assertion fails * @throws {Error} When the value is null * @example * ```typescript * function processData(data: string | null) { * assertNotNull(data); * return data.toUpperCase(); // TypeScript knows data is not null * } * ``` */ export declare function assertNotNull<T>(value: T | null, message?: string): asserts value is T;