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
We're only capable of combining contextual types when the source signatures come from the same declaration; making the parameters line up in the first position wouldn't be sufficient here.
Code
Expected behavior:
The type of
element
should benumber
, because the type offorEach
should be:Note: The type of
index
is not a mistake -Set
gives the current value twice, whileArray
gives the current index. It's weird.Actual behavior:
The type of
element
is inferred to beany
and has to be explicitly stated asnumber
.Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=9&pln=1&pc=1#code/C4TwDgpgBAMglgZ2AeQGYDkCuBbARhAJwSgF4oBlCYAHgDsd8CA+KAHynr0IG0BdAbgCwAKBGpMtAMbA4Ae1pQ4wQgENlCABQAbRMABcsXWixciASigBvEVCg6kAOlSyCAURWSAFhohaI2CFpgUhZrYVtbX39A4H4oAHp4qE8VYlBIKBVaEBsoAF8zIWE8oA
The text was updated successfully, but these errors were encountered: