Question about error handling in Typescript

This page summarizes the projects mentioned and recommended in the original post on /r/typescript

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.

  • Typed catch clauses are unfortunately not possible in TypeScript (although highly demanded). The closest to handle that would be to implement type guards that can identify your error and then handle it properly. I made a video about this technique: https://www.youtube.com/watch?v=0GLYiJUBz6k

  • fp-ts

    Functional programming in TypeScript

  • With fp-ts and sum-types you'd handle this functionally like so:

  • 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
  • sum-types

    Safe, ergonomic, non-generic sum types in TypeScript.

  • With fp-ts and sum-types you'd handle this functionally like so:

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