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
@RyanCavanaugh Thanks for linking that issue to this one. I would like to point out that this issue is less of a request for variance annotation syntax. The focus here is a type error that is missed by the the compiler, which indicates that the type inference system of TypeScript may not be sound.
TypeScript Version: 2.1.1
Code
Expected behavior:
A type error containing the following message should be reported by the compiler:
Actual behavior:
A successful compilation. Then, at runtime, a type error is thrown at the
compare
function ofCatCompare
:Discussion:
Although the compiler of TypeScript is able to catch a similar error as follows:
However, it seems that the compiler only makes sure that the built-in
Array
type is invariant. For other generic types, variance is not checked.The text was updated successfully, but these errors were encountered: