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
3.5 regression: union type as property accessor break function parameter inference #32038
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.
Activity
fregante commentedon Jun 22, 2019
This is probably due to #30769
But the types of
window.resizeToandwindow.resizeByare identical so there shouldn't be any difference or ambiguity.You can find a real-life example here: refined-github/refined-github#2164
ahejlsberg commentedon Jun 23, 2019
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.
fregante commentedon Jun 23, 2019
Great!
fregante commentedon Jul 1, 2019
I can confirm that this was fixed and works as expected in 3.6.0-dev.20190701
Thank you!