-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Better error recovery for adjacent JSX elements in expression positions #5295
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
Better error recovery for adjacent JSX elements in expression positions #5295
Conversation
@@ -72,8 +72,8 @@ baz | |||
<div>@test content</div>; | |||
<div><br />7x invalid-js-identifier</div>; | |||
<LeftRight left={<a />} right={<b>monkeys /> gorillas</b> / > }/> | |||
< a.b > ; | |||
a.b > ; | |||
, |
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.
is this ,
comes from synthesized missing node?
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.
Correct
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.
interesting, I didn't realize that we print missing nodes. In this case I'm not sure that user would expect to see it - this is our internal recovery strategy and I don' think it should leak outside. Maybe we should not emit missing nodes (since they are ...missed in the source code)
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.
This is consistent with what we've done for a while. For example if you write
var x = a b;
we emit
var x = a, b;
As I've said before, I don't think emitting in the presence of syntax errors is a rational thing to do, but since we're doing it anyway, I think the code we emit should at least be syntactically valid (even if it makes guesses at the intent).
👍 |
1 similar comment
👍 |
Better error recovery for adjacent JSX elements in expression positions
Fixes #5286