-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
babel-types lists JSXIdentifier as an Expression #6960
babel-types lists JSXIdentifier as an Expression #6960
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6224/ |
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.
Thank you for this pr!
The correct way of modifying a node type is updating it in the babel-types
package:
babel/packages/babel-types/src/definitions/jsx.js
Lines 91 to 99 in a7c9264
defineType("JSXIdentifier", { | |
builder: ["name"], | |
aliases: ["JSX", "Expression"], | |
fields: { | |
name: { | |
validate: assertValueType("string"), | |
}, | |
}, | |
}); |
Than you should run node scripts/generate-interfaces.js
to update lib/types.js
and node scripts/generate-babel-types-docs.js
to update packages/babel-types/README.md
Thanks for the pointer! Per your advice I have modified the right file and then generated it using the script. |
Did you also run |
Nope, just added. |
Anything else I need to do? Just checking in. |
…lement and JSXFragment are actually Expressions. Currently, Babel is treating JSXIdentifier, JSXMemberExpression, and JSXEmptyExpression as expressions as well, which means Babel will for example incorrectly allow you to place these anywhere an expression is wanted. This fixes that. Closes #6851.
Per the JSX definition ( https://facebook.github.io/jsx/ ), only JSXElement and JSXFragment are actually Expressions.
Currently, Babel is treating JSXIdentifier, JSXMemberExpression, and JSXEmptyExpression as expressions as well, which
means Babel will for example incorrectly allow you to place these anywhere an expression is wanted. This fixes that.
Closes #6851.
Not sure if anything else is necessary, this seemed to be the place to edit.