-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add JSXSpreadChild #59
Conversation
Are there any comments? Could we merge this? I’d like to see this functionality adopted in parsers, so it’s important to see this extension in the language. |
Seems fine to me. Merged. |
@@ -138,7 +138,7 @@ JSXChild : | |||
|
|||
- JSXText | |||
- JSXElement | |||
- `{` AssignmentExpression<sub>opt</sub> `}` | |||
- `{` JSXChildExpression `}` |
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.
nit: I would put opt
here. as it was before Technically it doesn't matter for the grammar, but would be cleaner to see that the content between braces is optional.
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.
Yeah, I like that better too 😉
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.
See #61
@calebmer @sebmarkbage Does anyone remember why we introduced a separate node type for this and not reused |
@RReverser I don’t think there was a specific reason. I defaulted to creating a new type which may be better for extensibility in the future. |
What does ESTree do for spread properties (object spread)? |
interface SpreadElement <: Node {
type: "SpreadElement";
argument: Expression;
} |
@sebmarkbage Ah sorry, just realised that I misunderstood your question. See https://github.com/estree/estree/blob/master/experimental/rest-spread-properties.md - it also reuses |
I'm skeptical of seeking reuse for things that are specified as separate things in the syntax spec. It seems like a fragile future compatibility issue and convenience issue. E.g. for matchers in Babel or for implementing evaluators. According to the last TC39 meeting, rest properties will no longer allow a nested pattern - unlike rest element. Only identifiers. So they've already diverged and might diverge more in the future. |
shrugs AST is mostly for syntactic representation of things, there are better IRs for evaluators and checkers. And syntactically this is indeed |
Summary: In facebook/jsx#59 spread children were added to the JSX specification. This adds type checking and parsing for spread children for CSX. Reviewed By: calebmer Differential Revision: D6236379 fbshipit-source-id: 5eca3b7b3748a47ff25e257fcb3c4778a73a5495
As per discussions in #57 and babel/babylon#42.
This syntax is the same one I used in writing babel/babylon#42
cc @syranide, @sebmarkbage, @kittens