diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-05-14 14:05:49 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-05-14 14:05:49 +0800 |
| commit | 06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch) | |
| tree | 4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/@babel/traverse/lib/scope/index.js | |
| parent | 1368909b3cd552dbb0d12d5863c597f5be46177d (diff) | |
updated node_modules
Diffstat (limited to 'node_modules/@babel/traverse/lib/scope/index.js')
| -rw-r--r-- | node_modules/@babel/traverse/lib/scope/index.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/node_modules/@babel/traverse/lib/scope/index.js b/node_modules/@babel/traverse/lib/scope/index.js index ed90029f..ff56a2a5 100644 --- a/node_modules/@babel/traverse/lib/scope/index.js +++ b/node_modules/@babel/traverse/lib/scope/index.js @@ -20,6 +20,7 @@ const { identifier, isArrayExpression, isBinary, + isCallExpression, isClass, isClassBody, isClassDeclaration, @@ -30,6 +31,7 @@ const { isIdentifier, isImportDeclaration, isLiteral, + isMemberExpression, isMethod, isModuleSpecifier, isNullLiteral, @@ -274,6 +276,9 @@ const collectorVisitor = { if (path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) { path.scope.registerBinding("local", path); } + }, + TSTypeAnnotation(path) { + path.skip(); } }; let uid = 0; @@ -622,13 +627,23 @@ class Scope { return true; } else if (isUnaryExpression(node)) { return this.isPure(node.argument, constantsOnly); - } else if (isTaggedTemplateExpression(node)) { - return matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly); } else if (isTemplateLiteral(node)) { for (const expression of node.expressions) { if (!this.isPure(expression, constantsOnly)) return false; } return true; + } else if (isTaggedTemplateExpression(node)) { + return matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", { + noGlobals: true + }) && this.isPure(node.quasi, constantsOnly); + } else if (isMemberExpression(node)) { + return !node.computed && isIdentifier(node.object) && node.object.name === "Symbol" && isIdentifier(node.property) && node.property.name !== "for" && !this.hasBinding("Symbol", { + noGlobals: true + }); + } else if (isCallExpression(node)) { + return matchesPattern(node.callee, "Symbol.for") && !this.hasBinding("Symbol", { + noGlobals: true + }) && node.arguments.length === 1 && t.isStringLiteral(node.arguments[0]); } else { return isPureish(node); } @@ -720,9 +735,9 @@ class Scope { kind = "var", id } = opts; - if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && t.isCallExpression(path.parent, { + if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && isCallExpression(path.parent, { callee: path.node - }) && path.parent.arguments.length <= path.node.params.length && t.isIdentifier(id)) { + }) && path.parent.arguments.length <= path.node.params.length && isIdentifier(id)) { path.pushContainer("params", id); path.scope.registerBinding("param", path.get("params")[path.node.params.length - 1]); return; |
