Probable bug: Can't infer an invariant generic on contravariant position when involving another generic #45255
Labels
Fix Available
A PR has been opened for this issue
Fixed
A PR has been merged for this issue
Suggestion
An idea for TypeScript
Milestone
Bug Report
π Search Terms
invariant generic, contravariant inference
Maybe related or perhaps because of the same design limitation mentioned in #44999
π Version & Regression Information
Tested with 4.3.5
β― Playground Link
Playground
π» Code
π Actual behavior
In 1st and 3rd function call
U
gets inferred tounknown
π Expected behavior
In 1st function call
U
should get inferred to"a"
and in 3rd function callU
should get inferred to"b"
.Clearly the contravariant position of
U
inm
seems to be a problem because if we annotate it (as done in 2nd call) or omit it (as done in 4th call) it gets inferred to what is expect and there are no error.A real world use case:
The text was updated successfully, but these errors were encountered: