assert
Asserts a condition. This function can be used as a assertion function in TypeScript.
function assert(
// Condition to assert
condition: unknown,
// The error to throw when `condition` is `false`
// If string is given, it wraps it with `new Error()`.
// @default new Error()
error: Error | string
): asserts condition;
Examples
let accountId: string | null;
assert(accountId != null, new Error('No "accountId"'));
accountId; // string (type guarded)