3 ms·
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 res
by vhakulinen 4y 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-typescript-result-monad/ https://thingsthatkeepmeupatnight.dev/posts/simple-typescrip...
- wereHamster 4y agoCongrats, you've re-invented sumtypes!
- vhakulinen 4y agoRather, copied over from other languages.