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

printer: Support type parameters on JSX components in TSX #1397

Merged
merged 2 commits into from
May 11, 2024

Conversation

PartMan7
Copy link

@PartMan7 PartMan7 commented Apr 8, 2024

Supports actually parsing cases like <Foo<Bar> /> instead of crashing.

Was unsure how to test this, since the existing code inherits from babel-parser's fixtures, and that doesn't currently have any tests of the sort (though it is a supported format).

Please let me know if there's any changes / modifications needed to the PR!

Demonstration on Babel REPL

@PartMan7 PartMan7 changed the title chore: Support type parameters on JSX components in TSX printer: Support type parameters on JSX components in TSX Apr 8, 2024
@eventualbuddha
Copy link
Collaborator

I'd add a test to test/jsx.ts.

@PartMan7
Copy link
Author

test/jsx.ts is currently only running with babel and esprima, which (please correct me if I'm wrong) don't support TypeScript syntax (eg: tests crash even with <b>{'a' as string}</b>, which is valid and supported TSX). From what I could tell, the TSX tests run for recast are limited to those directly taken from babel-parser's fixtures - could you please point me in the right direction?

@eventualbuddha
Copy link
Collaborator

I guess I'd probably create a test/tsx.ts file that parses with the typescript option and put the tests in there.

@PartMan7
Copy link
Author

PartMan7 commented May 2, 2024

Hope this works!

@eventualbuddha eventualbuddha merged commit b7beb30 into benjamn:master May 11, 2024
6 checks passed
@eventualbuddha
Copy link
Collaborator

Thanks! Published in v0.23.7.

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.

2 participants