Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Generic function causes parsing error #420

Closed
mariusschulz opened this issue Dec 21, 2017 · 3 comments
Closed

Generic function causes parsing error #420

mariusschulz opened this issue Dec 21, 2017 · 3 comments
Labels

Comments

@mariusschulz
Copy link
Contributor

What version of TypeScript are you using?
2.6.2

What version of typescript-eslint-parser are you using?
11.0.0

What code were you trying to parse?

index.ts within a TypeScript project with JSX enabled:

const id = <T>(x: T) => x;

What did you expect to happen?
No parsing error.

What happened?
A parsing error:

Parsing error: JSX element 'T' has no corresponding closing tag
@mightyiam
Copy link

Can't use the <T> syntax of type assertion with JSX, I think.

@mariusschulz
Copy link
Contributor Author

mariusschulz commented Dec 21, 2017

You're right, you can't use <T> for type assertions within .tsx files. However, in my example, I'm not using a type assertion and I'm also not within a .tsx file — I'm just declaring a type parameter to make the function generic. TypeScript happily compiles the code.

@JamesHenry
Copy link
Member

Thanks, @mariusschulz!

The issue is not limited to type assertions, it applies to any ambiguous constructs. This is one such construct. TypeScript cannot compile this with jsx enabled, which as you said is the case here.

This, therefore, comes under #399, so I am going to close this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants