-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: stricter type for promise rejection value/reason #17440
Comments
This has definitely been brought up before (eg here and here in more detail here). As you say, A suggested solution that I quite like has been made in #10715. However, updating all the |
@yortus I think TypeScript should just set the |
I do not think we will be open to taking such a breaking change in the standard library. a local change to the |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.4.1
Code
In this example, there is no type checking on property lookups on
error
becauseerror
has typeany
.I understand it is not possible to know the true type of a the rejected promise value/reason (see #5413). However, I would question whether we could replace
any
with the empty object type{}
.This would mean the above example would throw a type error, which is desirable because it is safer. The user may widen choose the type of
error
using user-defined type guards.Has this been considered at all? I am also curious if the same idea could be applied to other uses of
any
in libs.The text was updated successfully, but these errors were encountered: