Type alias NeverFallback<MaybeNever, Fallback>

NeverFallback<MaybeNever, Fallback>: Single<MaybeNever> extends Single<never>
    ? Fallback
    : MaybeNever

Takes a value that could be never, and if it is never it goes to the Fallback value.


There are some scenarios where a value can end up being of type never, this works sorta like the the ?? operator, but for never.


const value: never = (undefined as never);
NeverFallback<typeof value, number>; // Will be number

Type Parameters

  • MaybeNever

    The type that may or may not be never.

  • Fallback

    The fallback type to use if MaybeNever is never.