Order): number => { const [drink, size] = order; switch (drink) { case "coffee": switch (size) { case "small": return 100; case "medium": return 200; case "large": return 300; } case "tea": switch (size) { case "small": return 150; case "medium": return 250; case "large": return 350; } } } type Drink = "coffee" | "tea" | "soda"; type Size = "small" | "medium" | "large"; type Order = [Drink, Size]; const price = (order: Order): number => { return match(order) .with(["coffee", "small"], () => 100) .with(["coffee", "medium"], () => 200) .with(["coffee", "large"], () => 300) .with(["tea", "small"], () => 150) .with(["tea", "medium"], () => 250) .with(["tea", "large"], () => 350) .exhaustive(); }