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

Use TSX parser instead of Typescript parser for JavaScript and JSX #229

Merged
merged 5 commits into from
Aug 21, 2019

Conversation

maxbrunsfeld
Copy link
Contributor

@maxbrunsfeld maxbrunsfeld commented Aug 14, 2019

JavaScript (and .jsx) files can contain JSX (and cannot use TypeScript's type assertion syntax), so we need to use the TSX dialect of TypeScript when parsing and analyzing them.

@maxbrunsfeld
Copy link
Contributor Author

Is there any testing that should be added for this? Previously, we would have gotten parse errors on any .js files that used JSX, so maybe just a unit test that we can parse a .js file with some JSX in it?

@tclem
Copy link
Member

tclem commented Aug 14, 2019

Let's do something like this, but with a .jsx extension. You can use script/generate-example to help bootstrap the expected output.

maxbrunsfeld and others added 2 commits August 21, 2019 10:31
Also, add a unit test for JSX in JavaScript.

Co-Authored-By: Rick Winfrey <[email protected]>
@maxbrunsfeld
Copy link
Contributor Author

While we were here, @rewinfrey and I also added some limited support for Type arguments in TSX (microsoft/TypeScript#22415).

@@ -6,6 +6,7 @@
(JsxElement
(JsxOpeningElement
(Identifier)
(Empty)
Copy link
Contributor Author

@maxbrunsfeld maxbrunsfeld Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsxOpeningElement terms now have an optional TypeArguments child. We based this off the way that type arguments are handled in the New node.

Copy link
Member

@tclem tclem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can we do a manually run of the parse-examples target (we use to do this in CI, but travis can't quiet keep up with the workload)?

@maxbrunsfeld maxbrunsfeld merged commit b7a52b4 into master Aug 21, 2019
@maxbrunsfeld maxbrunsfeld deleted the use-tsx-for-js-and-flow branch August 21, 2019 18:44
@github github deleted a comment Aug 23, 2021
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