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

Support tsx files with exported typescript parser #535

Closed
wants to merge 3 commits into from
Closed

Support tsx files with exported typescript parser #535

wants to merge 3 commits into from

Conversation

evans
Copy link

@evans evans commented Aug 29, 2018

Adding the jsx plugin provides the ability to parse typescript files containing jsx syntax. See facebook/jscodeshift#180 (comment) for more color.

Adding the jsx plugin provides the ability to parse typescript files containing jsx syntax. See facebook/jscodeshift#180 (comment) for more color.
@benjamn
Copy link
Owner

benjamn commented Sep 8, 2018

Thanks for this, @evans! Those test failures seem relevant, though. I had thought that JSX conflicted with some TypeScript <type> syntax, or I would have enabled it by default.

@naruaway
Copy link

I think it is better to provide a new exported "tsx" parser rather than modifying existing "typescript" parser so that users can use it as they want.

@eventualbuddha
Copy link
Collaborator

This seems unlikely to move forward, so I’m closing it. Consumers of recast can easily add the jsx plugin if they like.

@kube
Copy link

kube commented Apr 19, 2022

It's a little bit sad to see that this was closed.

TSX has some syntax conflicts with generic type parameters (e.g. const fn = <T>(t: T) => t), but it is worked around in TypeScript by specifying extension (.tsx vs .ts).

Maybe we could reopen the PR, and just define it as a new parser.

I know that I can define plugins manually, but it was really close here.

For the parser name IMO it should be typescriptReact (at least it the official name):

Screenshot 2022-04-19 at 03 02 02

@kube
Copy link

kube commented Apr 19, 2022

Sorry, after trying, indeed there are collisions between syntaxes as the current PR defines plugins.

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

Successfully merging this pull request may close these issues.

5 participants