ignore function params, rest and catch clauses - webpack/webpack#688

This commit is contained in:
Sebastian McKenzie
2015-01-14 18:39:07 +11:00
parent f6a2acdfb1
commit f5f17f0ccb
2 changed files with 16 additions and 0 deletions

View File

@@ -193,6 +193,17 @@ t.isReferenced = function (node, parent) {
// we're a property key and we aren't computed so we aren't referenced
if (t.isProperty(parent) && parent.key === node && !parent.computed) return false;
if (t.isFunction(parent)) {
// we're a function param
if (_.contains(parent.params, node)) return false;
// we're a rest parameter
if (_.contains(parent.params, node)) return false;
}
// we're a catch clause param
if (t.isCatchClause(parent) && parent.param === node) return false;
// we're a variable declarator id so we aren't referenced
if (t.isVariableDeclarator(parent) && parent.id === node) return false;