core3-utils

@wixc3/common on Github

Home > @wixc3/common > UnreachableCaseError

UnreachableCaseError class

Allows the type checker to detect non-exhaustive switch statements.

Signature:

export declare class UnreachableCaseError extends Error 

Extends: Error

Example

declare const align: 'left' | 'right' | 'middle';
switch (align) {
    case 'left': return 1;
    case 'right': return 2;
    // type error since 'middle' is not handled
    default: throw new UnreachableCaseError(align);
}

Constructors

Constructor Modifiers Description
[(constructor)(switchValue)](/core3-utils/common.unreachablecaseerror._constructor_.html) Constructs a new instance of the `UnreachableCaseError` class