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
Conversation
// 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46802/ |
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:
|
This PR fixes regressions introduced in #13431. The token
!
hasbeforeExpr
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 setbeforeExpr
tofalse
, which is equivalent tostate.exprAllowed = false
so the JSX tag would not form after.This PR also fixes an issue that we are pushing duplicatetc.brace
token context when JSX plugin is enabled, one is insuper.updateContext
, the other is injsxPlugin.updateContext
. I am working on a test for this issue.I have removed this commit as it turns out
tt.brace
andtt.templateQuasi
is unifiable, and whensuper.updateContext
pushedtt.brace
, thejsxPlugin.updateContext
does not run at all. I will prepare a PR later.