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 }}
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Generic type parameter inferred differently across two call-site positions with opposite variance (narrow type vs union) #4683
D is inferred as MetricWithCardinality — resolved from the columns prop (a contravariant position, since D appears inside Cell's function parameter), not from data.
D is inferred as the full union instead — resolved from data (a covariant position). Since EnrichedMetricWithCardinality is a strict superset of MetricWithCardinality, both resolutions are arguably sound (the union collapses to MetricWithCardinality for assignability purposes), but the two compilers pick different candidates when resolving the same type parameter from two opposite-variance positions in the same call.
In real code, this difference in which candidate wins can cascade into a real TS2322 (columns declared for the narrow type fails against the wider inferred D) even though [email protected] accepts the exact same code
Activity
Andarist commentedon Jul 21, 2026
bisects to #4389
ahejlsberg commentedon Jul 21, 2026
This was fixed by #4591 which is now in main.