assertUnreachable (#1294)
This commit is contained in:
@@ -42,3 +42,11 @@ export function assertReturn <T> (value: T | undefined | null, message: string |
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name assertUnreachable
|
||||
* @description An assertion helper that ensures all codepaths are followed
|
||||
*/
|
||||
export function assertUnreachable (x: never): never {
|
||||
throw new Error(`This codepath should be unreachable. Unhandled input: ${x as unknown as string}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user