4 ms·
It helps that is has good smart-casting, you can do with an if where other languages need pattern matching const x: { t: 'A', foo: string } | { t: 'B', bar
by dtech 5y ago
It helps that is has good smart-casting, you can do with an if where other languages need pattern matching
const x: { t: 'A', foo: string } | { t: 'B', bar: string } = /*...*/
return x.t === 'A' ? x.foo : x.bar
- AzzieElbab 5y agoIt is cool syntax trick, but it won’t make compiler tell you when you missed a case