Hacker News new | ask | show | jobs
by dtech 1865 days 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
1 comments

It is cool syntax trick, but it won’t make compiler tell you when you missed a case