Hacker News new | past | comments | ask | show | jobs | submit login

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



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




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: