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

Disallow JSX tag forming after TS non-null assertion #13449

Merged
merged 1 commit into from Jun 10, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jun 10, 2021

Q                       A
Fixed Issues? Fixes #13445
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

This PR fixes regressions introduced in #13431. The token ! has beforeExpr because it can be a prefix operator in a Unary expression. However, when it is consumed as a postfix operator in non-null, we should set beforeExpr to false, which is equivalent to state.exprAllowed = false so the JSX tag would not form after.

This PR also fixes an issue that we are pushing duplicate tc.brace token context when JSX plugin is enabled, one is in super.updateContext, the other is in jsxPlugin.updateContext. I am working on a test for this issue.

I have removed this commit as it turns out tt.brace and tt.templateQuasi is unifiable, and when super.updateContext pushed tt.brace, the jsxPlugin.updateContext does not run at all. I will prepare a PR later.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser area: typescript i: regression area: jsx labels Jun 10, 2021
// When ! is consumed as a postfix operator (non-null assertion),
// disallow JSX tag forming after. e.g. When parsing `p! < n.p!`
// `<n.p` can not be a start of JSX tag
this.state.exprAllowed = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 10, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46802/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 10, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c376be7:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung merged commit b1fe831 into babel:main Jun 10, 2021
@JLHwung JLHwung deleted the fix-13445 branch June 10, 2021 19:07
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: jsx area: typescript i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: non-null assertion operator in comparison
4 participants