diff --git a/src/babel/traversal/path/virtual-types.js b/src/babel/traversal/path/virtual-types.js index 60459a567f..ad79e9d0cf 100644 --- a/src/babel/traversal/path/virtual-types.js +++ b/src/babel/traversal/path/virtual-types.js @@ -1,14 +1,14 @@ import * as t from "../../types"; export var ReferencedIdentifier = { - type: "Identifier", + types: ["Identifier", "JSXIdentifier"], checkPath(path, opts) { return t.isReferencedIdentifier(path.node, path.parent, opts); } }; export var Scope = { - type: "Scopable", + types: ["Scopable"], checkPath(path) { return t.isScope(path.node, path.parent); } @@ -27,7 +27,7 @@ export var BlockScoped = { }; export var Var = { - type: "VariableDeclaration", + types: ["VariableDeclaration"], checkPath(path) { return t.isVar(path.node); } diff --git a/src/babel/traversal/visitors.js b/src/babel/traversal/visitors.js index 55bd53d5d2..11d8332787 100644 --- a/src/babel/traversal/visitors.js +++ b/src/babel/traversal/visitors.js @@ -29,19 +29,21 @@ export function explode(visitor, mergeConflicts) { // wrap all the functions var fns = visitor[nodeType]; - for (var type in fns) { + for (let type in fns) { fns[type] = wrapCheck(wrapper, fns[type]); } // clear it from the visitor delete visitor[nodeType]; - if (wrapper.type) { - // merge the visitor if necessary or just put it back in - if (visitor[wrapper.type]) { - mergePair(visitor[wrapper.type], fns); - } else { - visitor[wrapper.type] = fns; + if (wrapper.types) { + for (let type of (wrapper.types: Array)) { + // merge the visitor if necessary or just put it back in + if (visitor[type]) { + mergePair(visitor[type], fns); + } else { + visitor[type] = fns; + } } } else { mergePair(visitor, fns);