Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 2x | /**
* Marks a code path as unreachable: in the `default` of a `switch` over a union, TypeScript fails when a
* member is not handled, and an unexpected value throws at run time.
*
* @param value - The value narrowed to `never`.
* @param message - The message of the error. Defaults to `'Unexpected value'`.
* @throws {Error} Always.
* @example
* switch (mode) {
* case 'day': return light;
* case 'night': return dark;
* default: return assertNever(mode);
* }
*/
export function assertNever(value: never, message = 'Unexpected value'): never {
throw new Error(message);
}
|