You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constarrFoo=async()=>['foo']constfoo=async()=>'foo'constbar=async()=>'bar'consttest=async()=>{constmapToBarPromises=[1,2,3].map(bar)constonlyBars=awaitPromise.all(mapToBarPromises)constonlyBarsSpread=awaitPromise.all([...mapToBarPromises])constmixed=awaitPromise.all([foo(),bar()])constmixedWithArr=awaitPromise.all([arrFoo(),bar()])constmixedWithSpread=awaitPromise.all([foo(), ...mapToBarPromises])// Fail when mixing spread with other arraysconstmixedArrAndSpread=awaitPromise.all([arrFoo(), ...mapToBarPromises])}
🙁 Actual behavior
TypeScript 4.2 Promise.all can't deal with a Promise<T1[]> plus a spread Promise<T2>
🙂 Expected behavior
This shouldn't be an error and in previous versions, it wasn't. Since it's very common for something async to return a list it makes it painful to do something like:
Sorry, I couldn't think of a less contrived example. More likely in code I see, the spread is a list of side effects updates, where we don't actually care about the result:
Bug Report
🔎 Search Terms
no overload matches call created:>=2021-01-01
promise created:>=2021-01-01
iterable created:>=2021-01-01
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
TypeScript 4.2
Promise.all
can't deal with aPromise<T1[]>
plus a spreadPromise<T2>
🙂 Expected behavior
This shouldn't be an error and in previous versions, it wasn't. Since it's very common for something async to return a list it makes it painful to do something like:
Sorry, I couldn't think of a less contrived example. More likely in code I see, the spread is a list of side effects updates, where we don't actually care about the result:
I can do
Promise.all<any>()
, but if we actually want the values, we have to do some elaborate typing that we shouldn't have to.The text was updated successfully, but these errors were encountered: