assertUnreachable (#1294)

This commit is contained in:
Jaco
2021-12-08 10:26:45 +02:00
committed by GitHub
parent 21c9e1aefd
commit 6ab85a42bb
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -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}`);
}