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
Yes, this is caused by #30769. When an indexed access type occurs on the target side of an assignment, we form an intersection instead of a union. When intersecting properties of the same type we just end up with a property of that type, however we don't remove duplicate call/construct signatures. So, in your example the intersection ends up being a type with two (identical) call signatures, at which point we no longer do contextual typing of parameters.
We can fix the issue by removing duplicate call/construct signatures in an intersection.
TypeScript Version: 3.5.2 (it works with 3.4.4). Also tested on 3.6.0-dev.20190622
Search Terms:
Code (not real-life, just a repro)
Expected behavior:
x
andy
are of typenumber
(like in 3.4)Actual behavior:
x
andy
are of typeany
Playground Link: (enable
noImplicitAny
, but it seems to be on 3.4)https://www.typescriptlang.org/play/#src=%0D%0Aconst%20actions%20%3D%20%5B'resizeTo'%2C%20'resizeBy'%5D%20as%20const%3B%0D%0Afor%20(const%20action%20of%20actions)%20%7B%0D%0A%09window%5Baction%5D%20%3D%20(x%2C%20y)%20%3D%3E%20%7B%0D%0A%09%09window%5Baction%5D(x%2C%20y)%3B%0D%0A%09%7D%0D%0A%7D
Related Issues:
#32037
The text was updated successfully, but these errors were encountered: