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
{{ message }}
Repository navigation
Promise.all on any produces Promise<Record<string, any>> #46169
asyncfunctionfoo(x: any){letabc=awaitPromise.all(x);letoops: any[]=abc;// ~~~~// error: Type '{ [x: string]: any; }' is missing the following properties from type 'any[]': length, pop, push, concat, and 26 more.}
Promise.all always produces an Array, so this behavior is undesirable.
What's happening if you can't tell is that any is a valid substitution for T extends unknown[]. Upon instantiation, we feed any through a mapped type which acts differently depending on if we've passed in an array or something else.
When instantiating with any, we could instead choose an array-like type when we encounter a deferred homomorphic mapped type that's bounded by an array-like type.
In other words Foo<any> would produce different results (e.g. any[]) compared to than Bar<any> (i.e. Record<string, any>) here:
That wouldn't always work, and could result in behavior that progressively changes every time we instantiate a mapped object type, but I think that's probably usually desirable anyway, and it would work here.
Activity
DanielRosenwasser commentedon Oct 2, 2021
When instantiating with
any, we could instead choose an array-like type when we encounter a deferred homomorphic mapped type that's bounded by an array-like type.In other words
Foo<any>would produce different results (e.g.any[]) compared to thanBar<any>(i.e.Record<string, any>) here:That wouldn't always work, and could result in behavior that progressively changes every time we instantiate a mapped object type, but I think that's probably usually desirable anyway, and it would work here.
DanielRosenwasser commentedon Oct 2, 2021
Probably something similar to this in
instantiateMappedTypeDanielRosenwasser commentedon Oct 11, 2021
Seems from our new errors report that TypeORM has two regressions from the
Promise.allcase: