-
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
resolve()
of a promise accepts undefined
when explicit generic type is specified
#36749
Comments
duplicate of #22040
It's an optional argument, and therefore accepts |
@jcalz yeah, seems to be a duplicate. This is really a shame. I raised it because this caused an issue in production for me just now and I was really surprised TS can't handle such a simple case. |
This came up recently in our team chat and it was surprising to several of us. According to @rbuckton:
So I’m going to leave this open so we can revisit it. |
Hi, I'm running into a similar problem with type specificity for a generic callback type in our code on the
Our desire is to explicitly disallow
Alas it seems |
I am confused. It well can be the result of ECMAScript spec or something, but all this doesn't make sense to me.
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
promise undefined
and I looked through all of the 5 pages + looked through FAQCode:
Expected behavior:
Both Functions should prevent me from doing writing stupid code at compile time.
Actual behavior:
Only second one does prevent me. First one allows runtime error to happened in the end.
Playground Link: http://www.typescriptlang.org/play/?ts=3.8.0-dev.20200211&ssl=1&ssc=1&pln=14&pc=4#code/C4TwDgpgBAKuEEEoF4oG8BQUoDcCGANgK4QBcUAdkQLYBGEATgNwYC+GAxgPYUDOwUYBH4ooACgCU5AAoMu1AJa8IAHjiQEAPhTbM2BhGBEGFShADuUWfKWr1iTWIO8uBHNGS6s2KM9fuxIgoAEwgAMwUKCGCJFmxWWLYWbj4BIX4AJlFJGTlFZTV4LR10b31DY1NrfIgAOj83CECQ8MjoxNYWdOBJWuAACwgKMVANAElUvAoODy9sFJcCOoIuAHMRoon+KZna-GI64C4AMQUAD2jJCTZYoA
Related Issues:
I don't understand where this
undefined
as one of the potential argument types is coming from:My
lib.es5.d.ts
contains this:My
lib.es2015.promise.d.ts
contains this:The text was updated successfully, but these errors were encountered: