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
In the contravariant example the type is inferred from the first argument, so test1 fails to typecheck, despite both test1 and test2 sharing the same argument types, just reversed. This is also different from the covariant case where types are properly unified in both test1 and test2
π Expected behavior
The behaviour for the covariant and contravariant case should match, so test1 should be inferred as <C extends { length: number; charCodeAt(_: number): number; }>() => C
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
"contravariant", "unification"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?jsx=0#code/MYewdgzgLgBKZQE4EMBuzEEtkJgXhgAoBKfAPhgG8AoGOcaegWwCNMwBTfGAHgGEoADzKEA+gEYAXEWCSBg0ngpgArgBs1AGhiiATNMKz5i5erXEDJmPPJErKsABMOAM3YdHMZBC9gAngDc1LT0kLBqHBAQovDQWJyeBPwwHIJQHE4+lBFgAOZQABaSqqwciAC+IrLWFjCqGrb1akF0sbBMIIgcMQxI7om8fClpGY5ZOflFJSxl2sAFGHwgzgCCUGLFKqWIFtNllYbSfLVNjWYtoYzp0OLcoKzuhBFRPWHxHtodXa9x-cQXbRg1ygujuIAenEIX26bXejm0z2isL+AN6MEQ3GB4hIQXKwUBoHQWBwsAIJFsNFaaPubE43H4QhEEkstnk2j0LKU1iEtRsXIczjcCS8PhwgWCVLCMERPz6wqSQ1S6UyVAmhU22wOvNsAtc-RFvnFksY0NlcPpipGKuyGUmGpmiDmC0QS1W61E9rKuy2Dq1Rx1Tj1wu8htRUqxYIhHCekSRvThn06MPjKJCgOBoIINMepuRCQRsbNqfKQA
π» Code
π Actual behavior
In the
contravariant
example the type is inferred from the first argument, sotest1
fails to typecheck, despite bothtest1
andtest2
sharing the same argument types, just reversed. This is also different from thecovariant
case where types are properly unified in bothtest1
andtest2
π Expected behavior
The behaviour for the covariant and contravariant case should match, so
test1
should be inferred as<C extends { length: number; charCodeAt(_: number): number; }>() => C
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: