Handling errors like a pro 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
  • ts-results

    A typescript implementation of Rust's Result object.

  • https://github.com/vultix/ts-results for the former.

  • burrido

    Do-notation for JavaScript

  • I haven’t tried this out myself but there’s libraries out there that emulate do notation with generators, if that’s any better than e.g. fp-ts’ Do. A quick Google search led me to burrido

  • 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
  • exceptionally

    A fully type-safe and lightweight way of using exceptions instead of throwing errors

  • I one also thought that handlong errors works better when havung a good structure but that didn't really plan out. I stopped throwing anything inside my codebases. The only way to get full knowledge over the possible outcomes of a function call is if the function also returns exceptions instead of throwing them. TypeScript will not help you if something gets thrown. I wrote my own little library to handle this: https://github.com/ivanhofer/exceptionally I recently discovered that there are also other solutions out there that do something similar. With such an approach you will also know after 5 and more levels of function calls if your code really covers all possible outcomes. Really useful for refactoings!

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