Typescript Promise rejection type

As explained in this issue, Promise doesn’t have different types for fulfilled and rejected promises. reject accepts any argument that doesn’t affect type of a promise.

Currently Promise cannot be typed any better. This results from the fact that a promise can be rejected by throwing inside then or catch (this is a preferable way to reject existing promise), and this cannot be handled by typing system; also, TypeScript also doesn’t have exception-specific types except never.

Leave a Comment