Asserts that a value is not null or undefined.
Error if the value is null or undefined.
const fn = (x?: number | null) => { assertIsNonNullable(x); // throws an error if x is null or undefined return x; // x has inferred type number}; Copy
const fn = (x?: number | null) => { assertIsNonNullable(x); // throws an error if x is null or undefined return x; // x has inferred type number};
The value to be asserted.
Asserts that a value is not null or undefined.
Throws
Error if the value is null or undefined.
Example