Hacker News new | ask | show | jobs
by vhakulinen 1524 days ago
Regarding the error handling case, I've played around with the idea of implementing a Result type with typescript and hiding the errors behind that. The end result looks something like this

    const res = await getJSON('/thingy');

    if (isErr(res)) {
      // Handle error.
      return;
    }
You can read the details from here: https://thingsthatkeepmeupatnight.dev/posts/simple-typescrip...
1 comments

Congrats, you've re-invented sumtypes!
Rather, copied over from other languages.