@babel/traverse 7.18.0 → 7.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/lib/path/context.js +5 -1
- package/lib/path/inference/index.js +9 -3
- package/lib/scope/index.js +2 -2
- package/lib/scope/lib/renamer.js +8 -16
- package/package.json +4 -4
package/lib/path/context.js
CHANGED
@@ -129,7 +129,11 @@ function stop() {
|
|
129
129
|
function setScope() {
|
130
130
|
if (this.opts && this.opts.noScope) return;
|
131
131
|
let path = this.parentPath;
|
132
|
-
|
132
|
+
|
133
|
+
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod()) {
|
134
|
+
path = path.parentPath;
|
135
|
+
}
|
136
|
+
|
133
137
|
let target;
|
134
138
|
|
135
139
|
while (path && !target) {
|
@@ -33,10 +33,16 @@ const {
|
|
33
33
|
} = _t;
|
34
34
|
|
35
35
|
function getTypeAnnotation() {
|
36
|
-
|
37
|
-
|
36
|
+
let type = this.getData("typeAnnotation");
|
37
|
+
|
38
|
+
if (type != null) {
|
39
|
+
return type;
|
40
|
+
}
|
41
|
+
|
42
|
+
type = this._getTypeAnnotation() || anyTypeAnnotation();
|
38
43
|
if (isTypeAnnotation(type)) type = type.typeAnnotation;
|
39
|
-
|
44
|
+
this.setData("typeAnnotation", type);
|
45
|
+
return type;
|
40
46
|
}
|
41
47
|
|
42
48
|
const typeAnnotationInferringNodes = new WeakSet();
|
package/lib/scope/index.js
CHANGED
@@ -368,9 +368,9 @@ class Scope {
|
|
368
368
|
path = this.path;
|
369
369
|
|
370
370
|
do {
|
371
|
-
const
|
371
|
+
const shouldSkip = path.key === "key" || path.listKey === "decorators";
|
372
372
|
path = path.parentPath;
|
373
|
-
if (
|
373
|
+
if (shouldSkip && path.isMethod()) path = path.parentPath;
|
374
374
|
if (path && path.isScope()) parent = path;
|
375
375
|
} while (path && !parent);
|
376
376
|
|
package/lib/scope/lib/renamer.js
CHANGED
@@ -11,8 +11,9 @@ var _helperSplitExportDeclaration = require("@babel/helper-split-export-declarat
|
|
11
11
|
|
12
12
|
var _t = require("@babel/types");
|
13
13
|
|
14
|
+
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
|
15
|
+
|
14
16
|
const {
|
15
|
-
VISITOR_KEYS,
|
16
17
|
assignmentExpression,
|
17
18
|
identifier,
|
18
19
|
toExpression,
|
@@ -30,7 +31,11 @@ const renameVisitor = {
|
|
30
31
|
|
31
32
|
Scope(path, state) {
|
32
33
|
if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
|
33
|
-
|
34
|
+
path.skip();
|
35
|
+
|
36
|
+
if (path.isMethod()) {
|
37
|
+
(0, _helperEnvironmentVisitor.requeueComputedKeyAndDecorators)(path);
|
38
|
+
}
|
34
39
|
}
|
35
40
|
},
|
36
41
|
|
@@ -130,17 +135,4 @@ class Renamer {
|
|
130
135
|
|
131
136
|
}
|
132
137
|
|
133
|
-
exports.default = Renamer;
|
134
|
-
|
135
|
-
function skipAllButComputedMethodKey(path) {
|
136
|
-
if (!path.isMethod() || !path.node.computed) {
|
137
|
-
path.skip();
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
|
141
|
-
const keys = VISITOR_KEYS[path.type];
|
142
|
-
|
143
|
-
for (const key of keys) {
|
144
|
-
if (key !== "key") path.skipKey(key);
|
145
|
-
}
|
146
|
-
}
|
138
|
+
exports.default = Renamer;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.18.
|
3
|
+
"version": "7.18.2",
|
4
4
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
5
5
|
"author": "The Babel Team (https://babel.dev/team)",
|
6
6
|
"homepage": "https://babel.dev/docs/en/next/babel-traverse",
|
@@ -17,13 +17,13 @@
|
|
17
17
|
"main": "./lib/index.js",
|
18
18
|
"dependencies": {
|
19
19
|
"@babel/code-frame": "^7.16.7",
|
20
|
-
"@babel/generator": "^7.18.
|
21
|
-
"@babel/helper-environment-visitor": "^7.
|
20
|
+
"@babel/generator": "^7.18.2",
|
21
|
+
"@babel/helper-environment-visitor": "^7.18.2",
|
22
22
|
"@babel/helper-function-name": "^7.17.9",
|
23
23
|
"@babel/helper-hoist-variables": "^7.16.7",
|
24
24
|
"@babel/helper-split-export-declaration": "^7.16.7",
|
25
25
|
"@babel/parser": "^7.18.0",
|
26
|
-
"@babel/types": "^7.18.
|
26
|
+
"@babel/types": "^7.18.2",
|
27
27
|
"debug": "^4.1.0",
|
28
28
|
"globals": "^11.1.0"
|
29
29
|
},
|