TypeScript: Control flow analysis for destructured discriminated unions

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • The above is caught in Flow when exact types are enabled but not in TS.

    TS issue https://github.com/microsoft/TypeScript/issues/12936

    TS has a concept of "freshness" which catches some of these mistakes when you construct y right in the arguments of x, but it gets easily broken by accident and without a warning.

    2. Nominal types, so you can have for example "Id" type that is a number but not to be mixed with other numbers, you can't just call a function that expects an Id with literal 42. Classes are nominal too, which I think is a solid choise.

    3. Type variance & related safeguards

        function x(y: { foo: string | number}) {

  • type-fest

    A collection of essential TypeScript types

  • I know you're entirely right, but sometimes I see things like this in Typescript and although I can walk through it with enough pause, it kinda makes my head implode when I glance at it:

    https://github.com/sindresorhus/type-fest/blob/main/source/r...

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts