top | item 31051258

(no title)

vhakulinen | 3 years 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...

discuss

order

wereHamster|3 years ago

Congrats, you've re-invented sumtypes!

vhakulinen|3 years ago

Rather, copied over from other languages.