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

feat: fix parsing comments in jsx #82

Merged
merged 7 commits into from
Jan 4, 2019
Merged

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Jan 1, 2019

@vjeux @Kovensky @j-f1
This PR fixes issue with // inside jsx

fixes: #6

const triviaScanner = ts.createScanner(
ast.languageVersion,
false,
ast.languageVariant,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have to provide language variant, 0/1

@armano2 armano2 changed the title feat: fix parsing comments in jsx WIP: feat: fix parsing comments in jsx Jan 1, 2019
@armano2 armano2 changed the title WIP: feat: fix parsing comments in jsx feat: fix parsing comments in jsx Jan 1, 2019
container.parent &&
container.parent.kind === ts.SyntaxKind.JsxOpeningElement &&
container.parent.parent &&
container.parent.parent.kind === ts.SyntaxKind.JsxElement
Copy link
Contributor Author

@armano2 armano2 Jan 2, 2019

Choose a reason for hiding this comment

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

i had to do this instead of checking if type is equal JsxSelfClosingElement due to:
https://github.com/JamesHenry/typescript-estree/blob/master/src/convert.ts#L2091

i'm going to change logic there latter, to not mutate TS tree

Copy link
Owner

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Excellent, thanks!

loc: true,
range: true,
tokens: true,
comment: true,
jsx: true
jsx: path.extname(filename) === '.js'
Copy link
Owner

Choose a reason for hiding this comment

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

Are we missing anything important when we only enable jsx on .js files and not the .ts files? How come this change was necessary for this fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was no test cases for ts files in comments
TypeAssertion has same syntax as JSX <FOO> can be jsx or TypeAssertion, this change make sure that ts files are parsed without jsx flag set to true

https://github.com/JamesHenry/typescript-estree/pull/82/files#diff-d60a9cddf78a1d18d2b1d6014049eba0

@JamesHenry
Copy link
Owner

The most recent breaking change affects this PR, so the build failed just FYI

Copy link
Owner

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Just need to take the latest breaking change from master into account

@JamesHenry JamesHenry merged commit af73af2 into JamesHenry:master Jan 4, 2019
@armano2 armano2 deleted the comments branch January 4, 2019 17:59
@JamesHenry
Copy link
Owner

🎉 This PR is included in version 10.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Miscategorises URLs as comments
2 participants