re: Type-Safe Error Handling In TypeScript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: The only thing I don’t like is that this brings us back to callbacks, which so elegantly got rid of with await.
 

Would be great if typescript allows pattern matching, then you’ll do

with(result){
   Err(e) => console.log(“error!”);
   Ok(value) => console.log(value);
}
 

Actually you can do something similar:

blog.logrocket.com/pattern-matchin...

It’s not as pretty as real pattern matching but it fits to this use car.

code of conduct - report abuse