Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic arrow functions are incorrectly identified as JSX elements #15785

Closed
mutsys opened this issue May 11, 2017 · 1 comment
Closed

generic arrow functions are incorrectly identified as JSX elements #15785

mutsys opened this issue May 11, 2017 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@mutsys
Copy link

mutsys commented May 11, 2017

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.
@mhegazy
Copy link
Contributor

mhegazy commented May 11, 2017

looks like a duplicate of #15713

@mhegazy mhegazy added the Duplicate An existing issue was already created label May 11, 2017
@mhegazy mhegazy closed this as completed May 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants