Class used to perform never type value checks in unreachable code.
remarks
import { Debug } from'ts-typedefs';
declareconst val: string | number;
if (typeof val === 'string') {
returnnull;
} elseif (typeof val === 'number') {
thrownew Debug.UnreachableCodeError(val); // compiler error: val is not of type `never`return;
} else {
thrownew Debug.UnreachableCodeError(val); // this is ok val has `never` type here
}
Class used to perform
never
type value checks in unreachable code.remarks
import { Debug } from 'ts-typedefs'; declare const val: string | number; if (typeof val === 'string') { return null; } else if (typeof val === 'number') { throw new Debug.UnreachableCodeError(val); // compiler error: val is not of type `never` return; } else { throw new Debug.UnreachableCodeError(val); // this is ok val has `never` type here }