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
The code should not compile because identity does not satisfy the constraints of GenericIdentityFn. Namely, it accepts an argument of type number and returns type string, whereas the interface GenericIdentityFn describes a function that accepts an argument of type T and returns type T.
TypeScript Version: 2.0.6
Code
Expected behavior:
The code should not compile because
identity
does not satisfy the constraints ofGenericIdentityFn
. Namely, it accepts an argument of typenumber
and returns typestring
, whereas the interfaceGenericIdentityFn
describes a function that accepts an argument of typeT
and returns typeT
.Actual behavior:
The code compiles.
Other notes:
This is based on an example from https://www.typescriptlang.org/docs/handbook/generics.html.
The text was updated successfully, but these errors were encountered: