Here's what I'm trying (not working):
interface I<T = any> {
value: T
}
// Doesn't work, "Cannot find name 'T'."
const foo = (i: I<T>): T => {
return i.value;
}
I've tried various places to stick <T>
in and around the method definition to try to get a new type variable name, but with no luck. Here's what does work, using function
syntax:
interface I<T = any> {
value: T
}
function foo<T> (i: I<T>): T {
return i.value;
}
Is there an equivalent syntax for inline/fat-arrow functions?