assertUnreachable (#1294)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
Changes:
|
||||
|
||||
- Expose `assertUnreachable` for codepaths that should not be followed
|
||||
- Swap to upstream `@noble/hashes`
|
||||
- Preserve all-caps word splits in `stringCamelCase`
|
||||
|
||||
|
||||
@@ -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