From ef6a023fe2a4421d63a39daa912de78046dbe7ba Mon Sep 17 00:00:00 2001 From: JanMalch <25508038+JanMalch@users.noreply.github.com> Date: Fri, 30 Oct 2020 11:40:36 +0100 Subject: [PATCH] fix: use AssertionError for unreachable --- index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 6fc6215..bf9587e 100644 --- a/index.ts +++ b/index.ts @@ -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) { @@ -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'); }