Skip to content

Commit

Permalink
add Expression alias for JSXMemberExpression & update condition
Browse files Browse the repository at this point in the history
  • Loading branch information
swandir committed Mar 29, 2022
1 parent e072ba9 commit f7973e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/babel-traverse/src/path/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ export function referencesImport(
): boolean {
if (!this.isReferencedIdentifier()) {
if (
(this.isMemberExpression() ||
this.isJSXMemberExpression() ||
this.isOptionalMemberExpression()) &&
(this.node.computed
? isStringLiteral(this.node.property, { value: importName })
: (this.node.property as t.Identifier).name === importName)
(this.isJSXMemberExpression() &&
(this.node.property as t.JSXIdentifier).name === importName) ||
((this.isMemberExpression() || this.isOptionalMemberExpression()) &&
(this.node.computed
? isStringLiteral(this.node.property, { value: importName })
: (this.node.property as t.Identifier).name === importName))
) {
const object = (
this as NodePath<t.MemberExpression | t.OptionalMemberExpression>
Expand Down
1 change: 1 addition & 0 deletions packages/babel-types/src/ast-types/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ export type Expression =
| OptionalCallExpression
| TypeCastExpression
| JSXElement
| JSXMemberExpression
| JSXFragment
| BindExpression
| DoExpression
Expand Down
1 change: 1 addition & 0 deletions packages/babel-types/src/definitions/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ defineType("JSXIdentifier", {

defineType("JSXMemberExpression", {
visitor: ["object", "property"],
aliases: ["Expression"],
fields: {
object: {
validate: assertNodeType("JSXMemberExpression", "JSXIdentifier"),
Expand Down
1 change: 1 addition & 0 deletions packages/babel-types/src/validators/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4357,6 +4357,7 @@ export function isExpression(
"OptionalCallExpression" === nodeType ||
"TypeCastExpression" === nodeType ||
"JSXElement" === nodeType ||
"JSXMemberExpression" === nodeType ||
"JSXFragment" === nodeType ||
"BindExpression" === nodeType ||
"DoExpression" === nodeType ||
Expand Down

0 comments on commit f7973e7

Please sign in to comment.