-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Promise.all is not resolve type promise in intellisense #8492
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
Comments
@sandersn can you take a look. |
@Thaina, I can't repro your fix. In fact, it seems like the problem arises from the constructor call, so I don't see how changing the type of The root cause is that the compiler can't do whole-program type inference, so it can't use the call The reason that the compiler infers So when the compiler requests the contextual type of |
@sandersn That's not my point I mean even that But it turn out that What I suspect is, |
The cause of this is discussed at #5254.
I'm curious as to why you think so. Can you elaborate? |
@DanielRosenwasser No it's not related in anyway. I only talk about Promise.all not a constructor of Promise. Just look at the Promise.all().then in my screenshot and you would see that the type of parameter named pairs is Promise which should not. It could be anything but Promise |
I think I understand a bit better, but now I can't repro the problem. I typed in almost exactly the code from your screenshot: Promise.all([new Promise((resolve, reject) => { resolve(2) })])
.then(pairs => pairs[0]); The type of Note that Promise.all([new Promise<number>((resolve, reject) => { resolve(2) })])
.then(pairs => pairs[0]); Now |
Never mind, I pasted in my own definition of |
Uh oh!
There was an error while loading. Please reload this page.
Promise.all
should be able to take array ofPromise<T>
and resolve array of TBut it not work as expect
As you can see
pairs
should benumber[]
Which cause from a problem in this file
So I fix it like this
The text was updated successfully, but these errors were encountered: