Skip to content

Commit

Permalink
fix: use AssertionError for unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMalch committed Oct 30, 2020
1 parent e898664 commit ef6a023
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export function error(
/**
* Asserts that a code branch is unreachable. If it is, the compiler will throw a type error.
* If this function is reached at runtime, an error will be thrown.
* @param _value a value
* @param value a value
* @throws AssertionError in any case
* @example
* function myFun(foo: MyEnum): string {
* switch(foo) {
Expand All @@ -263,6 +264,6 @@ export function error(
* }
* }
*/
export function unreachable(_value: never): never {
throw new Error('Reached an unreachable case');
export function unreachable(value: never): never {
throw new AssertionError('Reached an unreachable case');
}

0 comments on commit ef6a023

Please sign in to comment.