• match creates a pattern matching expression.

    • Use .with(pattern, handler) to pattern match on the input.
    • Use .exhaustive() or .otherwise(() => defaultValue) to end the expression and get the result.

    Read the documentation for match on GitHub

    Type Parameters

    • const input
    • output = typeof unset

    Parameters

    Returns Match<input, output>

    Example

    declare let input: "A" | "B";

    return match(input)
    .with("A", () => "It's an A!")
    .with("B", () => "It's a B!")
    .exhaustive();