I'm reading this section of the TypeScript documentation, under the generic types section, the following two are stated to be the equivalent:
Code Sample 1
function identity<T>(arg: T): T {
return arg;
}
let myIdentity: <T>(arg: T) => T = identity;
Code Sample 2
function identity<T>(arg: T): T {
return arg;
}
let myIdentity: {<T>(arg: T): T} = identity;
The documentation states this is possible due to the following.
We can also write the generic type as a call signature of an object literal type
Despite this line I'm still struggling to understand how the two are equivalent, is there any further documentation or explanation of what it means to be 'a call signature of an object literal type'.
I'm sorry I can't give any further explanation but I'm completely drawing a blank as to how the two are equivalent, to me the second type definition states that myIdentity should be an object?
Thanks.