@babel/traverse 8.0.0-rc.3 → 8.0.0-rc.4
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.
- package/lib/index.d.ts +46 -32
- package/lib/index.js +113 -123
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -26,27 +26,27 @@ const ExistentialTypeParam = ["ExistsTypeAnnotation"];
|
|
|
26
26
|
const NumericLiteralTypeAnnotation = ["NumberLiteralTypeAnnotation"];
|
|
27
27
|
const ForAwaitStatement = ["ForOfStatement"];
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const virtualTypes = /*#__PURE__*/Object.defineProperty({
|
|
30
30
|
__proto__: null,
|
|
31
|
-
BindingIdentifier
|
|
32
|
-
BlockScoped
|
|
33
|
-
ExistentialTypeParam
|
|
34
|
-
Expression
|
|
35
|
-
Flow
|
|
36
|
-
ForAwaitStatement
|
|
37
|
-
Generated
|
|
38
|
-
NumericLiteralTypeAnnotation
|
|
39
|
-
Pure
|
|
40
|
-
Referenced
|
|
41
|
-
ReferencedIdentifier
|
|
42
|
-
ReferencedMemberExpression
|
|
43
|
-
RestProperty
|
|
31
|
+
BindingIdentifier,
|
|
32
|
+
BlockScoped,
|
|
33
|
+
ExistentialTypeParam,
|
|
34
|
+
Expression,
|
|
35
|
+
Flow,
|
|
36
|
+
ForAwaitStatement,
|
|
37
|
+
Generated,
|
|
38
|
+
NumericLiteralTypeAnnotation,
|
|
39
|
+
Pure,
|
|
40
|
+
Referenced,
|
|
41
|
+
ReferencedIdentifier,
|
|
42
|
+
ReferencedMemberExpression,
|
|
43
|
+
RestProperty,
|
|
44
44
|
Scope: Scope$1,
|
|
45
|
-
SpreadProperty
|
|
46
|
-
Statement
|
|
47
|
-
User
|
|
48
|
-
Var
|
|
49
|
-
});
|
|
45
|
+
SpreadProperty,
|
|
46
|
+
Statement,
|
|
47
|
+
User,
|
|
48
|
+
Var
|
|
49
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
50
50
|
|
|
51
51
|
class TraversalContext {
|
|
52
52
|
constructor(opts, state) {
|
|
@@ -184,7 +184,7 @@ const {
|
|
|
184
184
|
isFlow: nodeIsFlow,
|
|
185
185
|
isForStatement,
|
|
186
186
|
isForXStatement,
|
|
187
|
-
isIdentifier: isIdentifier$
|
|
187
|
+
isIdentifier: isIdentifier$5,
|
|
188
188
|
isImportDeclaration: isImportDeclaration$1,
|
|
189
189
|
isImportSpecifier,
|
|
190
190
|
isJSXIdentifier,
|
|
@@ -207,7 +207,7 @@ function isReferencedIdentifier(opts) {
|
|
|
207
207
|
node,
|
|
208
208
|
parent
|
|
209
209
|
} = this;
|
|
210
|
-
if (isIdentifier$
|
|
210
|
+
if (isIdentifier$5(node, opts)) {
|
|
211
211
|
return nodeIsReferenced(node, parent, this.parentPath.parent);
|
|
212
212
|
} else if (isJSXIdentifier(node, opts)) {
|
|
213
213
|
if (!isJSXMemberExpression(parent) && isCompatTag(node.name)) return false;
|
|
@@ -229,7 +229,7 @@ function isBindingIdentifier() {
|
|
|
229
229
|
parent
|
|
230
230
|
} = this;
|
|
231
231
|
const grandparent = this.parentPath.parent;
|
|
232
|
-
return isIdentifier$
|
|
232
|
+
return isIdentifier$5(node) && isBinding(node, parent, grandparent);
|
|
233
233
|
}
|
|
234
234
|
function isStatement$1() {
|
|
235
235
|
const {
|
|
@@ -306,25 +306,25 @@ function isForAwaitStatement() {
|
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
|
|
309
|
+
const NodePath_virtual_types_validator = /*#__PURE__*/Object.defineProperty({
|
|
310
310
|
__proto__: null,
|
|
311
|
-
isBindingIdentifier
|
|
312
|
-
isBlockScoped
|
|
311
|
+
isBindingIdentifier,
|
|
312
|
+
isBlockScoped,
|
|
313
313
|
isExpression: isExpression$3,
|
|
314
|
-
isFlow
|
|
315
|
-
isForAwaitStatement
|
|
316
|
-
isGenerated
|
|
317
|
-
isPure
|
|
318
|
-
isReferenced
|
|
319
|
-
isReferencedIdentifier
|
|
320
|
-
isReferencedMemberExpression
|
|
321
|
-
isRestProperty
|
|
322
|
-
isScope
|
|
323
|
-
isSpreadProperty
|
|
314
|
+
isFlow,
|
|
315
|
+
isForAwaitStatement,
|
|
316
|
+
isGenerated,
|
|
317
|
+
isPure,
|
|
318
|
+
isReferenced,
|
|
319
|
+
isReferencedIdentifier,
|
|
320
|
+
isReferencedMemberExpression,
|
|
321
|
+
isRestProperty,
|
|
322
|
+
isScope,
|
|
323
|
+
isSpreadProperty,
|
|
324
324
|
isStatement: isStatement$1,
|
|
325
|
-
isUser
|
|
326
|
-
isVar
|
|
327
|
-
});
|
|
325
|
+
isUser,
|
|
326
|
+
isVar
|
|
327
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
328
328
|
|
|
329
329
|
const {
|
|
330
330
|
DEPRECATED_KEYS,
|
|
@@ -342,6 +342,12 @@ function isExplodedVisitor(visitor) {
|
|
|
342
342
|
function explode$1(visitor) {
|
|
343
343
|
if (isExplodedVisitor(visitor)) return visitor;
|
|
344
344
|
visitor._exploded = true;
|
|
345
|
+
if (Object.hasOwn(visitor, "blacklist")) {
|
|
346
|
+
if (!Object.hasOwn(visitor, "denylist")) {
|
|
347
|
+
throw new Error("The 'blacklist' visitor option has been renamed to 'denylist'. " + "Please update your configuration.");
|
|
348
|
+
}
|
|
349
|
+
delete visitor.blacklist;
|
|
350
|
+
}
|
|
345
351
|
for (const nodeType of Object.keys(visitor)) {
|
|
346
352
|
if (shouldIgnoreKey(nodeType)) continue;
|
|
347
353
|
const parts = nodeType.split("|");
|
|
@@ -417,7 +423,7 @@ function verify$1(visitor) {
|
|
|
417
423
|
}
|
|
418
424
|
if (shouldIgnoreKey(nodeType)) continue;
|
|
419
425
|
if (!TYPES.includes(nodeType)) {
|
|
420
|
-
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-rc.
|
|
426
|
+
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-rc.4"}`);
|
|
421
427
|
}
|
|
422
428
|
const visitors = visitor[nodeType];
|
|
423
429
|
if (typeof visitors === "object") {
|
|
@@ -521,6 +527,9 @@ function shouldIgnoreKey(key) {
|
|
|
521
527
|
if (key === "denylist" || key === "noScope" || key === "skipKeys") {
|
|
522
528
|
return true;
|
|
523
529
|
}
|
|
530
|
+
if (key === "blacklist") {
|
|
531
|
+
throw new Error("The 'blacklist' visitor option has been renamed to 'denylist'. " + "Please update your configuration.");
|
|
532
|
+
}
|
|
524
533
|
return false;
|
|
525
534
|
}
|
|
526
535
|
function mergePair(dest, src) {
|
|
@@ -547,14 +556,14 @@ function environmentVisitor(visitor) {
|
|
|
547
556
|
return merge([_environmentVisitor, visitor]);
|
|
548
557
|
}
|
|
549
558
|
|
|
550
|
-
|
|
559
|
+
const visitors = /*#__PURE__*/Object.defineProperty({
|
|
551
560
|
__proto__: null,
|
|
552
|
-
environmentVisitor
|
|
561
|
+
environmentVisitor,
|
|
553
562
|
explode: explode$1,
|
|
554
|
-
isExplodedVisitor
|
|
555
|
-
merge
|
|
563
|
+
isExplodedVisitor,
|
|
564
|
+
merge,
|
|
556
565
|
verify: verify$1
|
|
557
|
-
});
|
|
566
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
558
567
|
|
|
559
568
|
const {
|
|
560
569
|
getAssignmentIdentifiers: getAssignmentIdentifiers$1
|
|
@@ -826,16 +835,16 @@ function getOrCreateCachedPaths(node, parentPath) {
|
|
|
826
835
|
return paths;
|
|
827
836
|
}
|
|
828
837
|
|
|
829
|
-
|
|
838
|
+
const cache = /*#__PURE__*/Object.defineProperty({
|
|
830
839
|
__proto__: null,
|
|
831
|
-
clear
|
|
832
|
-
clearPath
|
|
833
|
-
clearScope
|
|
834
|
-
getCachedPaths
|
|
835
|
-
getOrCreateCachedPaths
|
|
840
|
+
clear,
|
|
841
|
+
clearPath,
|
|
842
|
+
clearScope,
|
|
843
|
+
getCachedPaths,
|
|
844
|
+
getOrCreateCachedPaths,
|
|
836
845
|
get path () { return pathsCache; },
|
|
837
846
|
get scope () { return scope; }
|
|
838
|
-
});
|
|
847
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
839
848
|
|
|
840
849
|
const {
|
|
841
850
|
assignmentExpression: assignmentExpression$3,
|
|
@@ -852,7 +861,7 @@ const {
|
|
|
852
861
|
isExportDefaultDeclaration,
|
|
853
862
|
isExportNamedDeclaration: isExportNamedDeclaration$1,
|
|
854
863
|
isFunctionDeclaration,
|
|
855
|
-
isIdentifier: isIdentifier$
|
|
864
|
+
isIdentifier: isIdentifier$4,
|
|
856
865
|
isImportDeclaration,
|
|
857
866
|
isLiteral: isLiteral$1,
|
|
858
867
|
isMemberExpression,
|
|
@@ -879,7 +888,6 @@ const {
|
|
|
879
888
|
isMetaProperty,
|
|
880
889
|
isPrivateName,
|
|
881
890
|
isExportDeclaration,
|
|
882
|
-
buildUndefinedNode: buildUndefinedNode$1,
|
|
883
891
|
sequenceExpression: sequenceExpression$2
|
|
884
892
|
} = _t;
|
|
885
893
|
function gatherNodeParts(node, parts) {
|
|
@@ -1208,7 +1216,7 @@ class Scope {
|
|
|
1208
1216
|
if (isThisExpression(node) || isSuper$1(node) || isTopicReference(node)) {
|
|
1209
1217
|
return true;
|
|
1210
1218
|
}
|
|
1211
|
-
if (isIdentifier$
|
|
1219
|
+
if (isIdentifier$4(node)) {
|
|
1212
1220
|
const binding = this.getBinding(node.name);
|
|
1213
1221
|
if (binding) {
|
|
1214
1222
|
return binding.constant;
|
|
@@ -1307,9 +1315,6 @@ class Scope {
|
|
|
1307
1315
|
this.registerBinding("unknown", path);
|
|
1308
1316
|
}
|
|
1309
1317
|
}
|
|
1310
|
-
buildUndefinedNode() {
|
|
1311
|
-
return buildUndefinedNode$1();
|
|
1312
|
-
}
|
|
1313
1318
|
registerConstantViolation(path) {
|
|
1314
1319
|
const ids = path.getAssignmentIdentifiers();
|
|
1315
1320
|
for (const name of Object.keys(ids)) {
|
|
@@ -1365,7 +1370,7 @@ class Scope {
|
|
|
1365
1370
|
return this.getProgramParent().referencesSet.has(name);
|
|
1366
1371
|
}
|
|
1367
1372
|
isPure(node, constantsOnly) {
|
|
1368
|
-
if (isIdentifier$
|
|
1373
|
+
if (isIdentifier$4(node)) {
|
|
1369
1374
|
const binding = this.getBinding(node.name);
|
|
1370
1375
|
if (!binding) return false;
|
|
1371
1376
|
if (constantsOnly) return binding.constant;
|
|
@@ -1426,7 +1431,7 @@ class Scope {
|
|
|
1426
1431
|
noGlobals: true
|
|
1427
1432
|
}) && this.isPure(node.quasi, constantsOnly);
|
|
1428
1433
|
} else if (isMemberExpression(node)) {
|
|
1429
|
-
return !node.computed && isIdentifier$
|
|
1434
|
+
return !node.computed && isIdentifier$4(node.object) && node.object.name === "Symbol" && isIdentifier$4(node.property) && node.property.name !== "for" && !this.hasBinding("Symbol", {
|
|
1430
1435
|
noGlobals: true
|
|
1431
1436
|
});
|
|
1432
1437
|
} else if (isCallExpression$1(node)) {
|
|
@@ -1531,7 +1536,7 @@ class Scope {
|
|
|
1531
1536
|
} = opts;
|
|
1532
1537
|
if (!init && !unique && (kind === "var" || kind === "let") && isAnonymousFunctionExpression(path) && isCallExpression$1(path.parent, {
|
|
1533
1538
|
callee: path.node
|
|
1534
|
-
}) && path.parent.arguments.length <= path.node.params.length && isIdentifier$
|
|
1539
|
+
}) && path.parent.arguments.length <= path.node.params.length && isIdentifier$4(id)) {
|
|
1535
1540
|
path.pushContainer("params", id);
|
|
1536
1541
|
path.scope.registerBinding("param", path.get("params")[path.node.params.length - 1]);
|
|
1537
1542
|
return;
|
|
@@ -2024,7 +2029,7 @@ const {
|
|
|
2024
2029
|
tupleTypeAnnotation,
|
|
2025
2030
|
unionTypeAnnotation,
|
|
2026
2031
|
voidTypeAnnotation: voidTypeAnnotation$1,
|
|
2027
|
-
isIdentifier: isIdentifier$
|
|
2032
|
+
isIdentifier: isIdentifier$3
|
|
2028
2033
|
} = _t;
|
|
2029
2034
|
function VariableDeclarator() {
|
|
2030
2035
|
if (!this.get("id").isIdentifier()) return;
|
|
@@ -2139,7 +2144,7 @@ function CallExpression() {
|
|
|
2139
2144
|
} = this.node;
|
|
2140
2145
|
if (isObjectKeys(callee)) {
|
|
2141
2146
|
return arrayTypeAnnotation(stringTypeAnnotation$1());
|
|
2142
|
-
} else if (isArrayFrom(callee) || isObjectValues(callee) || isIdentifier$
|
|
2147
|
+
} else if (isArrayFrom(callee) || isObjectValues(callee) || isIdentifier$3(callee, {
|
|
2143
2148
|
name: "Array"
|
|
2144
2149
|
})) {
|
|
2145
2150
|
return arrayTypeAnnotation(anyTypeAnnotation$1());
|
|
@@ -2173,39 +2178,39 @@ function resolveCall(callee) {
|
|
|
2173
2178
|
}
|
|
2174
2179
|
}
|
|
2175
2180
|
|
|
2176
|
-
|
|
2181
|
+
const inferers = /*#__PURE__*/Object.defineProperty({
|
|
2177
2182
|
__proto__: null,
|
|
2178
|
-
ArrayExpression
|
|
2183
|
+
ArrayExpression,
|
|
2179
2184
|
ArrowFunctionExpression: Func,
|
|
2180
|
-
AssignmentExpression
|
|
2181
|
-
BinaryExpression
|
|
2182
|
-
BooleanLiteral
|
|
2183
|
-
CallExpression
|
|
2185
|
+
AssignmentExpression,
|
|
2186
|
+
BinaryExpression,
|
|
2187
|
+
BooleanLiteral,
|
|
2188
|
+
CallExpression,
|
|
2184
2189
|
ClassDeclaration: Func,
|
|
2185
2190
|
ClassExpression: Func,
|
|
2186
|
-
ConditionalExpression
|
|
2191
|
+
ConditionalExpression,
|
|
2187
2192
|
FunctionDeclaration: Func,
|
|
2188
2193
|
FunctionExpression: Func,
|
|
2189
2194
|
Identifier: infererReference,
|
|
2190
|
-
LogicalExpression
|
|
2191
|
-
NewExpression
|
|
2192
|
-
NullLiteral
|
|
2193
|
-
NumericLiteral
|
|
2194
|
-
ObjectExpression
|
|
2195
|
-
ParenthesizedExpression
|
|
2196
|
-
RegExpLiteral
|
|
2197
|
-
RestElement
|
|
2198
|
-
SequenceExpression
|
|
2199
|
-
StringLiteral
|
|
2200
|
-
TSAsExpression
|
|
2201
|
-
TSNonNullExpression
|
|
2202
|
-
TaggedTemplateExpression
|
|
2203
|
-
TemplateLiteral
|
|
2204
|
-
TypeCastExpression
|
|
2205
|
-
UnaryExpression
|
|
2206
|
-
UpdateExpression
|
|
2207
|
-
VariableDeclarator
|
|
2208
|
-
});
|
|
2195
|
+
LogicalExpression,
|
|
2196
|
+
NewExpression,
|
|
2197
|
+
NullLiteral,
|
|
2198
|
+
NumericLiteral,
|
|
2199
|
+
ObjectExpression,
|
|
2200
|
+
ParenthesizedExpression,
|
|
2201
|
+
RegExpLiteral,
|
|
2202
|
+
RestElement,
|
|
2203
|
+
SequenceExpression,
|
|
2204
|
+
StringLiteral,
|
|
2205
|
+
TSAsExpression,
|
|
2206
|
+
TSNonNullExpression,
|
|
2207
|
+
TaggedTemplateExpression,
|
|
2208
|
+
TemplateLiteral,
|
|
2209
|
+
TypeCastExpression,
|
|
2210
|
+
UnaryExpression,
|
|
2211
|
+
UpdateExpression,
|
|
2212
|
+
VariableDeclarator
|
|
2213
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
2209
2214
|
|
|
2210
2215
|
const {
|
|
2211
2216
|
anyTypeAnnotation,
|
|
@@ -2215,7 +2220,7 @@ const {
|
|
|
2215
2220
|
isEmptyTypeAnnotation,
|
|
2216
2221
|
isFlowBaseAnnotation,
|
|
2217
2222
|
isGenericTypeAnnotation,
|
|
2218
|
-
isIdentifier: isIdentifier$
|
|
2223
|
+
isIdentifier: isIdentifier$2,
|
|
2219
2224
|
isMixedTypeAnnotation,
|
|
2220
2225
|
isNumberTypeAnnotation,
|
|
2221
2226
|
isStringTypeAnnotation,
|
|
@@ -2334,9 +2339,9 @@ function isGenericType(genericName) {
|
|
|
2334
2339
|
return true;
|
|
2335
2340
|
}
|
|
2336
2341
|
}
|
|
2337
|
-
return isGenericTypeAnnotation(type) && isIdentifier$
|
|
2342
|
+
return isGenericTypeAnnotation(type) && isIdentifier$2(type.id, {
|
|
2338
2343
|
name: genericName
|
|
2339
|
-
}) || isTSTypeReference(type) && isIdentifier$
|
|
2344
|
+
}) || isTSTypeReference(type) && isIdentifier$2(type.typeName, {
|
|
2340
2345
|
name: genericName
|
|
2341
2346
|
});
|
|
2342
2347
|
}
|
|
@@ -2430,7 +2435,7 @@ const {
|
|
|
2430
2435
|
isCallExpression,
|
|
2431
2436
|
isExportNamedDeclaration,
|
|
2432
2437
|
isExpression: isExpression$2,
|
|
2433
|
-
isIdentifier: isIdentifier$
|
|
2438
|
+
isIdentifier: isIdentifier$1,
|
|
2434
2439
|
isSequenceExpression,
|
|
2435
2440
|
isSuper,
|
|
2436
2441
|
thisExpression: thisExpression$1
|
|
@@ -2491,7 +2496,7 @@ function isHiddenInSequenceExpression(path) {
|
|
|
2491
2496
|
return isSequenceExpression(path.parent) && (last(path.parent.expressions) !== path.node || isHiddenInSequenceExpression(path.parentPath));
|
|
2492
2497
|
}
|
|
2493
2498
|
function isAlmostConstantAssignment(node, scope) {
|
|
2494
|
-
if (!isAssignmentExpression(node) || !isIdentifier$
|
|
2499
|
+
if (!isAssignmentExpression(node) || !isIdentifier$1(node.left)) {
|
|
2495
2500
|
return false;
|
|
2496
2501
|
}
|
|
2497
2502
|
const blockScope = scope.getBlockParent();
|
|
@@ -2627,7 +2632,7 @@ const {
|
|
|
2627
2632
|
assignmentExpression: assignmentExpression$1,
|
|
2628
2633
|
awaitExpression,
|
|
2629
2634
|
blockStatement: blockStatement$1,
|
|
2630
|
-
buildUndefinedNode,
|
|
2635
|
+
buildUndefinedNode: buildUndefinedNode$2,
|
|
2631
2636
|
callExpression: callExpression$1,
|
|
2632
2637
|
cloneNode: cloneNode$1,
|
|
2633
2638
|
conditionalExpression: conditionalExpression$1,
|
|
@@ -2824,8 +2829,8 @@ function gatherSequenceExpressions(nodes, declars) {
|
|
|
2824
2829
|
}
|
|
2825
2830
|
ensureLastUndefined = true;
|
|
2826
2831
|
} else if (isIfStatement(node)) {
|
|
2827
|
-
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], declars) : buildUndefinedNode();
|
|
2828
|
-
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], declars) : buildUndefinedNode();
|
|
2832
|
+
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], declars) : buildUndefinedNode$2();
|
|
2833
|
+
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], declars) : buildUndefinedNode$2();
|
|
2829
2834
|
if (!consequent || !alternate) return;
|
|
2830
2835
|
exprs.push(conditionalExpression$1(node.test, consequent, alternate));
|
|
2831
2836
|
} else if (isBlockStatement$1(node)) {
|
|
@@ -2840,7 +2845,7 @@ function gatherSequenceExpressions(nodes, declars) {
|
|
|
2840
2845
|
return;
|
|
2841
2846
|
}
|
|
2842
2847
|
}
|
|
2843
|
-
if (ensureLastUndefined) exprs.push(buildUndefinedNode());
|
|
2848
|
+
if (ensureLastUndefined) exprs.push(buildUndefinedNode$2());
|
|
2844
2849
|
if (exprs.length === 1) {
|
|
2845
2850
|
return exprs[0];
|
|
2846
2851
|
} else {
|
|
@@ -3236,13 +3241,12 @@ const {
|
|
|
3236
3241
|
conditionalExpression,
|
|
3237
3242
|
expressionStatement,
|
|
3238
3243
|
identifier,
|
|
3239
|
-
isIdentifier: isIdentifier$1,
|
|
3240
3244
|
jsxIdentifier,
|
|
3241
3245
|
logicalExpression,
|
|
3242
3246
|
LOGICAL_OPERATORS,
|
|
3243
3247
|
memberExpression,
|
|
3244
3248
|
metaProperty,
|
|
3245
|
-
numericLiteral
|
|
3249
|
+
numericLiteral,
|
|
3246
3250
|
objectExpression,
|
|
3247
3251
|
restElement,
|
|
3248
3252
|
returnStatement,
|
|
@@ -3252,7 +3256,7 @@ const {
|
|
|
3252
3256
|
super: _super,
|
|
3253
3257
|
thisExpression,
|
|
3254
3258
|
toExpression,
|
|
3255
|
-
unaryExpression
|
|
3259
|
+
unaryExpression,
|
|
3256
3260
|
toBindingIdentifierName,
|
|
3257
3261
|
isFunction,
|
|
3258
3262
|
isAssignmentPattern,
|
|
@@ -3263,22 +3267,9 @@ const {
|
|
|
3263
3267
|
variableDeclarator,
|
|
3264
3268
|
exportNamedDeclaration,
|
|
3265
3269
|
exportSpecifier,
|
|
3266
|
-
inherits
|
|
3270
|
+
inherits,
|
|
3271
|
+
buildUndefinedNode: buildUndefinedNode$1
|
|
3267
3272
|
} = _t;
|
|
3268
|
-
function toComputedKey() {
|
|
3269
|
-
let key;
|
|
3270
|
-
if (this.isMemberExpression()) {
|
|
3271
|
-
key = this.node.property;
|
|
3272
|
-
} else if (this.isProperty() || this.isMethod()) {
|
|
3273
|
-
key = this.node.key;
|
|
3274
|
-
} else {
|
|
3275
|
-
throw new ReferenceError("todo");
|
|
3276
|
-
}
|
|
3277
|
-
if (!this.node.computed) {
|
|
3278
|
-
if (isIdentifier$1(key)) key = stringLiteral(key.name);
|
|
3279
|
-
}
|
|
3280
|
-
return key;
|
|
3281
|
-
}
|
|
3282
3273
|
function ensureBlock() {
|
|
3283
3274
|
const body = this.get("body");
|
|
3284
3275
|
const bodyNode = body.node;
|
|
@@ -3417,7 +3408,7 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
|
|
3417
3408
|
const argumentsBinding = getBinding(thisEnvFn, "arguments", () => {
|
|
3418
3409
|
const args = () => identifier("arguments");
|
|
3419
3410
|
if (thisEnvFn.scope.path.isProgram()) {
|
|
3420
|
-
return conditionalExpression(binaryExpression("===", unaryExpression
|
|
3411
|
+
return conditionalExpression(binaryExpression("===", unaryExpression("typeof", args()), stringLiteral("undefined")), buildUndefinedNode$1(), args());
|
|
3421
3412
|
} else {
|
|
3422
3413
|
return args();
|
|
3423
3414
|
}
|
|
@@ -3526,7 +3517,7 @@ function standardizeSuperProperty(superProp) {
|
|
|
3526
3517
|
const updateExpr = superProp.parentPath;
|
|
3527
3518
|
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
|
3528
3519
|
const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
|
|
3529
|
-
const parts = [assignmentExpression("=", tmp, memberExpression(superProp.node.object, computedKey ? assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), assignmentExpression("=", memberExpression(superProp.node.object, computedKey ? identifier(computedKey.name) : superProp.node.property, superProp.node.computed), binaryExpression(superProp.parentPath.node.operator[0], identifier(tmp.name), numericLiteral
|
|
3520
|
+
const parts = [assignmentExpression("=", tmp, memberExpression(superProp.node.object, computedKey ? assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), assignmentExpression("=", memberExpression(superProp.node.object, computedKey ? identifier(computedKey.name) : superProp.node.property, superProp.node.computed), binaryExpression(superProp.parentPath.node.operator[0], identifier(tmp.name), numericLiteral(1)))];
|
|
3530
3521
|
if (!superProp.parentPath.node.prefix) {
|
|
3531
3522
|
parts.push(identifier(tmp.name));
|
|
3532
3523
|
}
|
|
@@ -3820,7 +3811,8 @@ const {
|
|
|
3820
3811
|
isLiteral,
|
|
3821
3812
|
isStringLiteral,
|
|
3822
3813
|
isType,
|
|
3823
|
-
matchesPattern: _matchesPattern
|
|
3814
|
+
matchesPattern: _matchesPattern,
|
|
3815
|
+
toComputedKey
|
|
3824
3816
|
} = _t;
|
|
3825
3817
|
function matchesPattern(pattern, allowPartial) {
|
|
3826
3818
|
return _matchesPattern(this.node, pattern, allowPartial);
|
|
@@ -4074,7 +4066,7 @@ function _resolve(dangerous, resolved) {
|
|
|
4074
4066
|
} else if (this.isTypeCastExpression()) {
|
|
4075
4067
|
return this.get("expression").resolve(dangerous, resolved);
|
|
4076
4068
|
} else if (dangerous && this.isMemberExpression()) {
|
|
4077
|
-
const targetKey = this.
|
|
4069
|
+
const targetKey = toComputedKey(this.node);
|
|
4078
4070
|
if (!isLiteral(targetKey)) return;
|
|
4079
4071
|
const targetName = targetKey.value;
|
|
4080
4072
|
const target = this.get("object").resolve(dangerous, resolved);
|
|
@@ -4171,8 +4163,7 @@ const {
|
|
|
4171
4163
|
getAssignmentIdentifiers: _getAssignmentIdentifiers,
|
|
4172
4164
|
getBindingIdentifiers: _getBindingIdentifiers,
|
|
4173
4165
|
getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
|
|
4174
|
-
|
|
4175
|
-
unaryExpression
|
|
4166
|
+
buildUndefinedNode
|
|
4176
4167
|
} = _t;
|
|
4177
4168
|
const NORMAL_COMPLETION = 0;
|
|
4178
4169
|
const BREAK_COMPLETION = 1;
|
|
@@ -4236,7 +4227,7 @@ function replaceBreakStatementInBreakCompletion(completions, reachable) {
|
|
|
4236
4227
|
label: null
|
|
4237
4228
|
})) {
|
|
4238
4229
|
if (reachable) {
|
|
4239
|
-
c.path.replaceWith(
|
|
4230
|
+
c.path.replaceWith(buildUndefinedNode());
|
|
4240
4231
|
} else {
|
|
4241
4232
|
c.path.remove();
|
|
4242
4233
|
}
|
|
@@ -4683,7 +4674,6 @@ const methods = {
|
|
|
4683
4674
|
replaceInline: replaceInline,
|
|
4684
4675
|
evaluateTruthy: evaluateTruthy,
|
|
4685
4676
|
evaluate: evaluate,
|
|
4686
|
-
toComputedKey: toComputedKey,
|
|
4687
4677
|
ensureBlock: ensureBlock,
|
|
4688
4678
|
unwrapFunctionEnvironment: unwrapFunctionEnvironment,
|
|
4689
4679
|
arrowFunctionToExpression: arrowFunctionToExpression,
|