top | item 25159844

(no title)

macca321 | 5 years ago

Better to return a union of custom result types. Save exceptions for when stuff goes really wrong.

discuss

order

eyelidlessness|5 years ago

Unfortunately that’s not idiomatic in many common JS/TS scenarios, and requires deep familiarity with the internals of any APIs or third party libraries that throw errors. Optional typed exceptions would be right in line with the TS approach of modeling real world JS usage, but for the syntactical question of exhaustive error handling. (Of course that could be addressed separately or not at all.)

emteycz|5 years ago

It would be better to improve typing of Promise and try/catch than additional layers, IMHO