menu
148 tokens
Patterns and Match
Pattern matching.
Patterns and Match
patterns
refutable vs irrefutable
match
Sequencetype... except for dynamic index signatures where it types as
V | undefined(via dynamic.find)ranges:
..switch still works but match encouraged
let, let-else
if let
while let
match guards
No Computed Keys
no
obj[expr]whereexpris dynamicdestructure dynamically with
{ [key]: value }?
1enum State { Pending, Running, Complete }2declare const state: State;3 4const label = match (state) {5 State.Pending => "pending",6 State.Running => "running",7 State.Complete => "complete",8};