match creates a pattern matching expression.
match
.with(pattern, handler)
.exhaustive()
.otherwise(() => defaultValue)
Read the documentation for match on GitHub
declare let input: "A" | "B"; return match(input) .with("A", () => "It's an A!") .with("B", () => "It's a B!") .exhaustive(); Copy
declare let input: "A" | "B"; return match(input) .with("A", () => "It's an A!") .with("B", () => "It's a B!") .exhaustive();
match
creates a pattern matching expression..with(pattern, handler)
to pattern match on the input..exhaustive()
or.otherwise(() => defaultValue)
to end the expression and get the result.Read the documentation for
match
on GitHub