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
Type argument inference does not take call's contextual type into account #10245
error TS2322: Type 'number[][]' is not assignable to type '[number, number][]'.
Type 'number[]' is not assignable to type '[number, number]'.
Property '0' is missing in type 'number[]'.
What's happening here is that the call to array.map doesn't try to infer its return type from its contextual type. It only tries to infer from its arguments.
A workaround would be to give [number, number] as a type argument to map:
changed the title [-]Incorrect contextual type inferred[/-][+]Type argument inference does not take call's contextual type into account[/+]on Aug 10, 2016
@whiteblackkeys Unrelated. Root cause is #241 - function return expression widening causes the object literal freshness to be lost, causing excess properties to not be checked.
Activity
DanielRosenwasser commentedon Aug 10, 2016
What's happening here is that the call to
array.mapdoesn't try to infer its return type from its contextual type. It only tries to infer from its arguments.A workaround would be to give
[number, number]as a type argument tomap:[-]Incorrect contextual type inferred[/-][+]Type argument inference does not take call's contextual type into account[/+]manueledones commentedon Jan 16, 2019
Daniel Rosenwasser (@DanielRosenwasser) Here some other examples:
`
Is this the expected behavior or a bug?
RyanCavanaugh commentedon Jan 16, 2019
@whiteblackkeys Unrelated. Root cause is #241 - function return expression widening causes the object literal freshness to be lost, causing excess properties to not be checked.
ahejlsberg commentedon Mar 22, 2019
Fixed by #29478.