Closed
Description
TypeScript Version: 2.3.2
Code
this statement causes an error
const foo = <P>(bar: P): void => {
console.log(bar);
};
while the equivalent statement written with the function
keyword does not:
function foo<P>(bar: P): void {
console.log(bar);
}
it seems that as long as there is some other statement that precedes the generic declaration, the statement is recognized as valid. this next example is also recognized as valid:
const foo = (): <P>(bar: P) => void => {
return function<P>(bar: P): void {
console.log(bar);
};
}
however, changing the inner function to an arrow function also results in the same error.
Expected behavior:
the expression is evaluated and recognized as valid
Actual behavior:
an error is produced:
[ts] cannot find name 'P'.
[ts] JSX element 'P' has no corresponding closing tag.