matchWithNumberOtherwise
matchWithNumberOtherwise() handles selected members of a number literal union. Matcher keys must belong to the input union, but may omit cases. The otherwise callback receives only the literals that have no handler.
Interactive example
Syntax
Classic signature
typescript
function matchWithNumberOtherwise<Input extends number, Matcher, Output>(
input: Input,
matcher: Matcher,
otherwise: (value: UnhandledValues) => Output
): MatcherResult | OutputCurried signature
typescript
function matchWithNumberOtherwise<Input extends number, Matcher, Output>(
matcher: Matcher,
otherwise: (value: UnhandledValues) => Output
): (input: Input) => MatcherResult | OutputParameters
input: a number literal or literal union; broadnumbervalues are rejected.matcher: a partial object whose keys can only be members ofinput. A property may beundefinedto route that case tootherwise.otherwise: receives the exact union of cases without a handler.
Return value
The selected handler result, or the otherwise result for an unhandled value.
See also
matchWithNumber- Exhaustive number matching.matchWithStringOtherwise- String partial matching.
