Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 32 lines · 691 B · at 9472e3c

type Method = "GET" | "POST" | "DELETE";// Literal arms that cover a finite union need no _ arm.const verb = (m: Method): string =>  match (m) {    "GET" => "read",    "POST" => "write",    "DELETE" => "remove",  };const sign = (n: -1 | 0 | 1): string =>  match (n) {    -1 => "negative",    0 => "zero",    1 => "positive",  };const toggle = (on: boolean): string =>  match (on) {    true => "on",    false => "off",  };// A plain number is not finite, so it needs _.const status = (code: number): string =>  match (code) {    200 => "ok",    404 => "missing",    _ => "other",  };console.log(verb("POST"), sign(-1), toggle(false), status(404), status(500));