Reference
Tagged unions + exhaustive match are how UI states and errors stay honest.
| Type | Constructors |
|---|---|
Option<T> / T? | Some(x) · None |
Result<T,E> | Ok(x) · Err(e) |
Async<T> | Loading · Loaded(x) · Error(e) |
Matching a sum or literal union without covering all arms is a compile error. Wildcard _ is allowed but is an explicit “I am discarding remaining cases” — preferred for foreign decode defaults, not for papering over missing UI states.
match v {
{ user: { name: String }, tags: [String] } => /* narrowed */,
_ => /* false shape */,
}
Runtime typeof / Array.isArray checks; nested records and arrays supported.