@babel/traverse 7.12.7 → 7.12.12
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/family.js
CHANGED
@@ -25,9 +25,9 @@ function getTypeAnnotation() {
|
|
25
25
|
return this.typeAnnotation = type;
|
26
26
|
}
|
27
27
|
|
28
|
-
|
29
|
-
var _inferer;
|
28
|
+
const typeAnnotationInferringNodes = new WeakSet();
|
30
29
|
|
30
|
+
function _getTypeAnnotation() {
|
31
31
|
const node = this.node;
|
32
32
|
|
33
33
|
if (!node) {
|
@@ -53,16 +53,28 @@ function _getTypeAnnotation() {
|
|
53
53
|
return node.typeAnnotation;
|
54
54
|
}
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
if (inferer) {
|
59
|
-
return inferer.call(this, node);
|
56
|
+
if (typeAnnotationInferringNodes.has(node)) {
|
57
|
+
return;
|
60
58
|
}
|
61
59
|
|
62
|
-
|
60
|
+
typeAnnotationInferringNodes.add(node);
|
61
|
+
|
62
|
+
try {
|
63
|
+
var _inferer;
|
64
|
+
|
65
|
+
let inferer = inferers[node.type];
|
63
66
|
|
64
|
-
|
65
|
-
|
67
|
+
if (inferer) {
|
68
|
+
return inferer.call(this, node);
|
69
|
+
}
|
70
|
+
|
71
|
+
inferer = inferers[this.parentPath.type];
|
72
|
+
|
73
|
+
if ((_inferer = inferer) == null ? void 0 : _inferer.validParent) {
|
74
|
+
return this.parentPath.getTypeAnnotation();
|
75
|
+
}
|
76
|
+
} finally {
|
77
|
+
typeAnnotationInferringNodes.delete(node);
|
66
78
|
}
|
67
79
|
}
|
68
80
|
|
package/lib/path/modification.js
CHANGED
@@ -186,7 +186,7 @@ function unshiftContainer(listKey, nodes) {
|
|
186
186
|
container: this.node[listKey],
|
187
187
|
listKey,
|
188
188
|
key: 0
|
189
|
-
});
|
189
|
+
}).setContext(this.context);
|
190
190
|
|
191
191
|
return path._containerInsertBefore(nodes);
|
192
192
|
}
|
@@ -203,7 +203,7 @@ function pushContainer(listKey, nodes) {
|
|
203
203
|
container: container,
|
204
204
|
listKey,
|
205
205
|
key: container.length
|
206
|
-
});
|
206
|
+
}).setContext(this.context);
|
207
207
|
|
208
208
|
return path.replaceWithMultiple(nodes);
|
209
209
|
}
|
package/lib/path/replacement.js
CHANGED
@@ -57,13 +57,13 @@ const hoistVariablesVisitor = {
|
|
57
57
|
};
|
58
58
|
|
59
59
|
function replaceWithMultiple(nodes) {
|
60
|
+
var _pathCache$get;
|
61
|
+
|
60
62
|
this.resync();
|
61
63
|
nodes = this._verifyNodeList(nodes);
|
62
64
|
t.inheritLeadingComments(nodes[0], this.node);
|
63
65
|
t.inheritTrailingComments(nodes[nodes.length - 1], this.node);
|
64
|
-
|
65
|
-
_cache.path.get(this.parent).delete(this.node);
|
66
|
-
|
66
|
+
(_pathCache$get = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get.delete(this.node);
|
67
67
|
this.node = this.container[this.key] = null;
|
68
68
|
const paths = this.insertAfter(nodes);
|
69
69
|
|
@@ -167,6 +167,8 @@ function replaceWith(replacement) {
|
|
167
167
|
}
|
168
168
|
|
169
169
|
function _replaceWith(node) {
|
170
|
+
var _pathCache$get2;
|
171
|
+
|
170
172
|
if (!this.container) {
|
171
173
|
throw new ReferenceError("Container is falsy");
|
172
174
|
}
|
@@ -178,6 +180,7 @@ function _replaceWith(node) {
|
|
178
180
|
}
|
179
181
|
|
180
182
|
this.debug(`Replace with ${node == null ? void 0 : node.type}`);
|
183
|
+
(_pathCache$get2 = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get2.set(node, this).delete(this.node);
|
181
184
|
this.node = this.container[this.key] = node;
|
182
185
|
}
|
183
186
|
|
package/lib/scope/lib/renamer.js
CHANGED
@@ -104,7 +104,15 @@ class Renamer {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
107
|
-
|
107
|
+
const blockToTraverse = block || scope.block;
|
108
|
+
|
109
|
+
if ((blockToTraverse == null ? void 0 : blockToTraverse.type) === "SwitchStatement") {
|
110
|
+
blockToTraverse.cases.forEach(c => {
|
111
|
+
scope.traverse(c, renameVisitor, this);
|
112
|
+
});
|
113
|
+
} else {
|
114
|
+
scope.traverse(blockToTraverse, renameVisitor, this);
|
115
|
+
}
|
108
116
|
|
109
117
|
if (!block) {
|
110
118
|
scope.removeOwnBinding(oldName);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.12.
|
3
|
+
"version": "7.12.12",
|
4
4
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
5
5
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
6
6
|
"homepage": "https://babeljs.io/",
|
@@ -15,12 +15,12 @@
|
|
15
15
|
},
|
16
16
|
"main": "lib/index.js",
|
17
17
|
"dependencies": {
|
18
|
-
"@babel/code-frame": "^7.
|
19
|
-
"@babel/generator": "^7.12.
|
20
|
-
"@babel/helper-function-name": "^7.
|
21
|
-
"@babel/helper-split-export-declaration": "^7.11
|
22
|
-
"@babel/parser": "^7.12.
|
23
|
-
"@babel/types": "^7.12.
|
18
|
+
"@babel/code-frame": "^7.12.11",
|
19
|
+
"@babel/generator": "^7.12.11",
|
20
|
+
"@babel/helper-function-name": "^7.12.11",
|
21
|
+
"@babel/helper-split-export-declaration": "^7.12.11",
|
22
|
+
"@babel/parser": "^7.12.11",
|
23
|
+
"@babel/types": "^7.12.12",
|
24
24
|
"debug": "^4.1.0",
|
25
25
|
"globals": "^11.1.0",
|
26
26
|
"lodash": "^4.17.19"
|