@babel/traverse 8.0.0-alpha.1 → 8.0.0-alpha.3

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.
Files changed (59) hide show
  1. package/lib/index.js +171 -160
  2. package/lib/index.js.map +1 -1
  3. package/package.json +11 -10
  4. package/lib/cache.js +0 -14
  5. package/lib/cache.js.map +0 -1
  6. package/lib/context.js +0 -108
  7. package/lib/context.js.map +0 -1
  8. package/lib/hub.js +0 -12
  9. package/lib/hub.js.map +0 -1
  10. package/lib/path/ancestry.js +0 -126
  11. package/lib/path/ancestry.js.map +0 -1
  12. package/lib/path/comments.js +0 -46
  13. package/lib/path/comments.js.map +0 -1
  14. package/lib/path/context.js +0 -194
  15. package/lib/path/context.js.map +0 -1
  16. package/lib/path/conversion.js +0 -453
  17. package/lib/path/conversion.js.map +0 -1
  18. package/lib/path/evaluation.js +0 -333
  19. package/lib/path/evaluation.js.map +0 -1
  20. package/lib/path/family.js +0 -322
  21. package/lib/path/family.js.map +0 -1
  22. package/lib/path/index.js +0 -185
  23. package/lib/path/index.js.map +0 -1
  24. package/lib/path/inference/index.js +0 -137
  25. package/lib/path/inference/index.js.map +0 -1
  26. package/lib/path/inference/inferer-reference.js +0 -145
  27. package/lib/path/inference/inferer-reference.js.map +0 -1
  28. package/lib/path/inference/inferers.js +0 -172
  29. package/lib/path/inference/inferers.js.map +0 -1
  30. package/lib/path/inference/util.js +0 -20
  31. package/lib/path/inference/util.js.map +0 -1
  32. package/lib/path/introspection.js +0 -360
  33. package/lib/path/introspection.js.map +0 -1
  34. package/lib/path/lib/hoister.js +0 -164
  35. package/lib/path/lib/hoister.js.map +0 -1
  36. package/lib/path/lib/removal-hooks.js +0 -31
  37. package/lib/path/lib/removal-hooks.js.map +0 -1
  38. package/lib/path/lib/virtual-types-validator.js +0 -138
  39. package/lib/path/lib/virtual-types-validator.js.map +0 -1
  40. package/lib/path/lib/virtual-types.js +0 -20
  41. package/lib/path/lib/virtual-types.js.map +0 -1
  42. package/lib/path/modification.js +0 -209
  43. package/lib/path/modification.js.map +0 -1
  44. package/lib/path/removal.js +0 -46
  45. package/lib/path/removal.js.map +0 -1
  46. package/lib/path/replacement.js +0 -192
  47. package/lib/path/replacement.js.map +0 -1
  48. package/lib/scope/binding.js +0 -78
  49. package/lib/scope/binding.js.map +0 -1
  50. package/lib/scope/index.js +0 -870
  51. package/lib/scope/index.js.map +0 -1
  52. package/lib/scope/lib/renamer.js +0 -105
  53. package/lib/scope/lib/renamer.js.map +0 -1
  54. package/lib/traverse-node.js +0 -19
  55. package/lib/traverse-node.js.map +0 -1
  56. package/lib/types.js +0 -3
  57. package/lib/types.js.map +0 -1
  58. package/lib/visitors.js +0 -210
  59. package/lib/visitors.js.map +0 -1
@@ -1,453 +0,0 @@
1
- import * as _t from "@babel/types";
2
- const {
3
- arrowFunctionExpression,
4
- assignmentExpression,
5
- binaryExpression,
6
- blockStatement,
7
- callExpression,
8
- conditionalExpression,
9
- expressionStatement,
10
- identifier,
11
- isIdentifier,
12
- jsxIdentifier,
13
- logicalExpression,
14
- LOGICAL_OPERATORS,
15
- memberExpression,
16
- metaProperty,
17
- numericLiteral,
18
- objectExpression,
19
- restElement,
20
- returnStatement,
21
- sequenceExpression,
22
- spreadElement,
23
- stringLiteral,
24
- super: _super,
25
- thisExpression,
26
- toExpression,
27
- unaryExpression
28
- } = _t;
29
- import environmentVisitor from "@babel/helper-environment-visitor";
30
- import nameFunction from "@babel/helper-function-name";
31
- import { merge as mergeVisitors } from "../visitors.js";
32
- export function toComputedKey() {
33
- let key;
34
- if (this.isMemberExpression()) {
35
- key = this.node.property;
36
- } else if (this.isProperty() || this.isMethod()) {
37
- key = this.node.key;
38
- } else {
39
- throw new ReferenceError("todo");
40
- }
41
- if (!this.node.computed) {
42
- if (isIdentifier(key)) key = stringLiteral(key.name);
43
- }
44
- return key;
45
- }
46
- export function ensureBlock() {
47
- const body = this.get("body");
48
- const bodyNode = body.node;
49
- if (Array.isArray(body)) {
50
- throw new Error("Can't convert array path to a block statement");
51
- }
52
- if (!bodyNode) {
53
- throw new Error("Can't convert node without a body");
54
- }
55
- if (body.isBlockStatement()) {
56
- return bodyNode;
57
- }
58
- const statements = [];
59
- let stringPath = "body";
60
- let key;
61
- let listKey;
62
- if (body.isStatement()) {
63
- listKey = "body";
64
- key = 0;
65
- statements.push(body.node);
66
- } else {
67
- stringPath += ".body.0";
68
- if (this.isFunction()) {
69
- key = "argument";
70
- statements.push(returnStatement(body.node));
71
- } else {
72
- key = "expression";
73
- statements.push(expressionStatement(body.node));
74
- }
75
- }
76
- this.node.body = blockStatement(statements);
77
- const parentPath = this.get(stringPath);
78
- body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
79
- return this.node;
80
- }
81
- ;
82
- export function unwrapFunctionEnvironment() {
83
- if (!this.isArrowFunctionExpression() && !this.isFunctionExpression() && !this.isFunctionDeclaration()) {
84
- throw this.buildCodeFrameError("Can only unwrap the environment of a function.");
85
- }
86
- hoistFunctionEnvironment(this);
87
- }
88
- function setType(path, type) {
89
- path.node.type = type;
90
- }
91
- export function arrowFunctionToExpression({
92
- allowInsertArrow = true,
93
- allowInsertArrowWithRest = allowInsertArrow,
94
- noNewArrows = true
95
- } = {}) {
96
- if (!this.isArrowFunctionExpression()) {
97
- throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
98
- }
99
- const {
100
- thisBinding,
101
- fnPath: fn
102
- } = hoistFunctionEnvironment(this, noNewArrows, allowInsertArrow, allowInsertArrowWithRest);
103
- fn.ensureBlock();
104
- setType(fn, "FunctionExpression");
105
- if (!noNewArrows) {
106
- const checkBinding = thisBinding ? null : fn.scope.generateUidIdentifier("arrowCheckId");
107
- if (checkBinding) {
108
- fn.parentPath.scope.push({
109
- id: checkBinding,
110
- init: objectExpression([])
111
- });
112
- }
113
- fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)])));
114
- fn.replaceWith(callExpression(memberExpression(nameFunction(this, true) || fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
115
- return fn.get("callee.object");
116
- }
117
- return fn;
118
- }
119
- const getSuperCallsVisitor = mergeVisitors([{
120
- CallExpression(child, {
121
- allSuperCalls
122
- }) {
123
- if (!child.get("callee").isSuper()) return;
124
- allSuperCalls.push(child);
125
- }
126
- }, environmentVisitor]);
127
- function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true, allowInsertArrowWithRest = true) {
128
- let arrowParent;
129
- let thisEnvFn = fnPath.findParent(p => {
130
- if (p.isArrowFunctionExpression()) {
131
- arrowParent ??= p;
132
- return false;
133
- }
134
- return p.isFunction() || p.isProgram() || p.isClassProperty({
135
- static: false
136
- }) || p.isClassPrivateProperty({
137
- static: false
138
- });
139
- });
140
- const inConstructor = thisEnvFn.isClassMethod({
141
- kind: "constructor"
142
- });
143
- if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) {
144
- if (arrowParent) {
145
- thisEnvFn = arrowParent;
146
- } else if (allowInsertArrow) {
147
- fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), []));
148
- thisEnvFn = fnPath.get("callee");
149
- fnPath = thisEnvFn.get("body");
150
- } else {
151
- throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
152
- }
153
- }
154
- const {
155
- thisPaths,
156
- argumentsPaths,
157
- newTargetPaths,
158
- superProps,
159
- superCalls
160
- } = getScopeInformation(fnPath);
161
- if (inConstructor && superCalls.length > 0) {
162
- if (!allowInsertArrow) {
163
- throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super()` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
164
- }
165
- if (!allowInsertArrowWithRest) {
166
- throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-parameters', " + "it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
167
- }
168
- const allSuperCalls = [];
169
- thisEnvFn.traverse(getSuperCallsVisitor, {
170
- allSuperCalls
171
- });
172
- const superBinding = getSuperBinding(thisEnvFn);
173
- allSuperCalls.forEach(superCall => {
174
- const callee = identifier(superBinding);
175
- callee.loc = superCall.node.callee.loc;
176
- superCall.get("callee").replaceWith(callee);
177
- });
178
- }
179
- if (argumentsPaths.length > 0) {
180
- const argumentsBinding = getBinding(thisEnvFn, "arguments", () => {
181
- const args = () => identifier("arguments");
182
- if (thisEnvFn.scope.path.isProgram()) {
183
- return conditionalExpression(binaryExpression("===", unaryExpression("typeof", args()), stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args());
184
- } else {
185
- return args();
186
- }
187
- });
188
- argumentsPaths.forEach(argumentsChild => {
189
- const argsRef = identifier(argumentsBinding);
190
- argsRef.loc = argumentsChild.node.loc;
191
- argumentsChild.replaceWith(argsRef);
192
- });
193
- }
194
- if (newTargetPaths.length > 0) {
195
- const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => metaProperty(identifier("new"), identifier("target")));
196
- newTargetPaths.forEach(targetChild => {
197
- const targetRef = identifier(newTargetBinding);
198
- targetRef.loc = targetChild.node.loc;
199
- targetChild.replaceWith(targetRef);
200
- });
201
- }
202
- if (superProps.length > 0) {
203
- if (!allowInsertArrow) {
204
- throw superProps[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super.prop` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration.");
205
- }
206
- const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
207
- flatSuperProps.forEach(superProp => {
208
- const key = superProp.node.computed ? "" : superProp.get("property").node.name;
209
- const superParentPath = superProp.parentPath;
210
- const isAssignment = superParentPath.isAssignmentExpression({
211
- left: superProp.node
212
- });
213
- const isCall = superParentPath.isCallExpression({
214
- callee: superProp.node
215
- });
216
- const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({
217
- tag: superProp.node
218
- });
219
- const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
220
- const args = [];
221
- if (superProp.node.computed) {
222
- args.push(superProp.get("property").node);
223
- }
224
- if (isAssignment) {
225
- const value = superParentPath.node.right;
226
- args.push(value);
227
- }
228
- const call = callExpression(identifier(superBinding), args);
229
- if (isCall) {
230
- superParentPath.unshiftContainer("arguments", thisExpression());
231
- superProp.replaceWith(memberExpression(call, identifier("call")));
232
- thisPaths.push(superParentPath.get("arguments.0"));
233
- } else if (isAssignment) {
234
- superParentPath.replaceWith(call);
235
- } else if (isTaggedTemplate) {
236
- superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()]));
237
- thisPaths.push(superProp.get("arguments.0"));
238
- } else {
239
- superProp.replaceWith(call);
240
- }
241
- });
242
- }
243
- let thisBinding;
244
- if (thisPaths.length > 0 || !noNewArrows) {
245
- thisBinding = getThisBinding(thisEnvFn, inConstructor);
246
- if (noNewArrows || inConstructor && hasSuperClass(thisEnvFn)) {
247
- thisPaths.forEach(thisChild => {
248
- const thisRef = thisChild.isJSX() ? jsxIdentifier(thisBinding) : identifier(thisBinding);
249
- thisRef.loc = thisChild.node.loc;
250
- thisChild.replaceWith(thisRef);
251
- });
252
- if (!noNewArrows) thisBinding = null;
253
- }
254
- }
255
- return {
256
- thisBinding,
257
- fnPath
258
- };
259
- }
260
- function isLogicalOp(op) {
261
- return LOGICAL_OPERATORS.includes(op);
262
- }
263
- function standardizeSuperProperty(superProp) {
264
- if (superProp.parentPath.isAssignmentExpression() && superProp.parentPath.node.operator !== "=") {
265
- const assignmentPath = superProp.parentPath;
266
- const op = assignmentPath.node.operator.slice(0, -1);
267
- const value = assignmentPath.node.right;
268
- const isLogicalAssignment = isLogicalOp(op);
269
- if (superProp.node.computed) {
270
- const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
271
- const object = superProp.node.object;
272
- const property = superProp.node.property;
273
- assignmentPath.get("left").replaceWith(memberExpression(object, assignmentExpression("=", tmp, property), true));
274
- assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(tmp.name), true), value));
275
- } else {
276
- const object = superProp.node.object;
277
- const property = superProp.node.property;
278
- assignmentPath.get("left").replaceWith(memberExpression(object, property));
279
- assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(property.name)), value));
280
- }
281
- if (isLogicalAssignment) {
282
- assignmentPath.replaceWith(logicalExpression(op, assignmentPath.node.left, assignmentPath.node.right));
283
- } else {
284
- assignmentPath.node.operator = "=";
285
- }
286
- return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
287
- } else if (superProp.parentPath.isUpdateExpression()) {
288
- const updateExpr = superProp.parentPath;
289
- const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
290
- const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
291
- 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)))];
292
- if (!superProp.parentPath.node.prefix) {
293
- parts.push(identifier(tmp.name));
294
- }
295
- updateExpr.replaceWith(sequenceExpression(parts));
296
- const left = updateExpr.get("expressions.0.right");
297
- const right = updateExpr.get("expressions.1.left");
298
- return [left, right];
299
- }
300
- return [superProp];
301
- function rightExpression(op, left, right) {
302
- if (op === "=") {
303
- return assignmentExpression("=", left, right);
304
- } else {
305
- return binaryExpression(op, left, right);
306
- }
307
- }
308
- }
309
- function hasSuperClass(thisEnvFn) {
310
- return thisEnvFn.isClassMethod() && !!thisEnvFn.parentPath.parentPath.node.superClass;
311
- }
312
- const assignSuperThisVisitor = mergeVisitors([{
313
- CallExpression(child, {
314
- supers,
315
- thisBinding
316
- }) {
317
- if (!child.get("callee").isSuper()) return;
318
- if (supers.has(child.node)) return;
319
- supers.add(child.node);
320
- child.replaceWithMultiple([child.node, assignmentExpression("=", identifier(thisBinding), identifier("this"))]);
321
- }
322
- }, environmentVisitor]);
323
- function getThisBinding(thisEnvFn, inConstructor) {
324
- return getBinding(thisEnvFn, "this", thisBinding => {
325
- if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();
326
- thisEnvFn.traverse(assignSuperThisVisitor, {
327
- supers: new WeakSet(),
328
- thisBinding
329
- });
330
- });
331
- }
332
- function getSuperBinding(thisEnvFn) {
333
- return getBinding(thisEnvFn, "supercall", () => {
334
- const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
335
- return arrowFunctionExpression([restElement(argsBinding)], callExpression(_super(), [spreadElement(identifier(argsBinding.name))]));
336
- });
337
- }
338
- function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
339
- const op = isAssignment ? "set" : "get";
340
- return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => {
341
- const argsList = [];
342
- let fnBody;
343
- if (propName) {
344
- fnBody = memberExpression(_super(), identifier(propName));
345
- } else {
346
- const method = thisEnvFn.scope.generateUidIdentifier("prop");
347
- argsList.unshift(method);
348
- fnBody = memberExpression(_super(), identifier(method.name), true);
349
- }
350
- if (isAssignment) {
351
- const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
352
- argsList.push(valueIdent);
353
- fnBody = assignmentExpression("=", fnBody, identifier(valueIdent.name));
354
- }
355
- return arrowFunctionExpression(argsList, fnBody);
356
- });
357
- }
358
- function getBinding(thisEnvFn, key, init) {
359
- const cacheKey = "binding:" + key;
360
- let data = thisEnvFn.getData(cacheKey);
361
- if (!data) {
362
- const id = thisEnvFn.scope.generateUidIdentifier(key);
363
- data = id.name;
364
- thisEnvFn.setData(cacheKey, data);
365
- thisEnvFn.scope.push({
366
- id: id,
367
- init: init(data)
368
- });
369
- }
370
- return data;
371
- }
372
- const getScopeInformationVisitor = mergeVisitors([{
373
- ThisExpression(child, {
374
- thisPaths
375
- }) {
376
- thisPaths.push(child);
377
- },
378
- JSXIdentifier(child, {
379
- thisPaths
380
- }) {
381
- if (child.node.name !== "this") return;
382
- if (!child.parentPath.isJSXMemberExpression({
383
- object: child.node
384
- }) && !child.parentPath.isJSXOpeningElement({
385
- name: child.node
386
- })) {
387
- return;
388
- }
389
- thisPaths.push(child);
390
- },
391
- CallExpression(child, {
392
- superCalls
393
- }) {
394
- if (child.get("callee").isSuper()) superCalls.push(child);
395
- },
396
- MemberExpression(child, {
397
- superProps
398
- }) {
399
- if (child.get("object").isSuper()) superProps.push(child);
400
- },
401
- Identifier(child, {
402
- argumentsPaths
403
- }) {
404
- if (!child.isReferencedIdentifier({
405
- name: "arguments"
406
- })) return;
407
- let curr = child.scope;
408
- do {
409
- if (curr.hasOwnBinding("arguments")) {
410
- curr.rename("arguments");
411
- return;
412
- }
413
- if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {
414
- break;
415
- }
416
- } while (curr = curr.parent);
417
- argumentsPaths.push(child);
418
- },
419
- MetaProperty(child, {
420
- newTargetPaths
421
- }) {
422
- if (!child.get("meta").isIdentifier({
423
- name: "new"
424
- })) return;
425
- if (!child.get("property").isIdentifier({
426
- name: "target"
427
- })) return;
428
- newTargetPaths.push(child);
429
- }
430
- }, environmentVisitor]);
431
- function getScopeInformation(fnPath) {
432
- const thisPaths = [];
433
- const argumentsPaths = [];
434
- const newTargetPaths = [];
435
- const superProps = [];
436
- const superCalls = [];
437
- fnPath.traverse(getScopeInformationVisitor, {
438
- thisPaths,
439
- argumentsPaths,
440
- newTargetPaths,
441
- superProps,
442
- superCalls
443
- });
444
- return {
445
- thisPaths,
446
- argumentsPaths,
447
- newTargetPaths,
448
- superProps,
449
- superCalls
450
- };
451
- }
452
-
453
- //# sourceMappingURL=conversion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_t","arrowFunctionExpression","assignmentExpression","binaryExpression","blockStatement","callExpression","conditionalExpression","expressionStatement","identifier","isIdentifier","jsxIdentifier","logicalExpression","LOGICAL_OPERATORS","memberExpression","metaProperty","numericLiteral","objectExpression","restElement","returnStatement","sequenceExpression","spreadElement","stringLiteral","super","_super","thisExpression","toExpression","unaryExpression","environmentVisitor","nameFunction","merge","mergeVisitors","toComputedKey","key","isMemberExpression","node","property","isProperty","isMethod","ReferenceError","computed","name","ensureBlock","body","get","bodyNode","Array","isArray","Error","isBlockStatement","statements","stringPath","listKey","isStatement","push","isFunction","parentPath","setup","unwrapFunctionEnvironment","isArrowFunctionExpression","isFunctionExpression","isFunctionDeclaration","buildCodeFrameError","hoistFunctionEnvironment","setType","path","type","arrowFunctionToExpression","allowInsertArrow","allowInsertArrowWithRest","noNewArrows","thisBinding","fnPath","fn","checkBinding","scope","generateUidIdentifier","id","init","unshiftContainer","hub","addHelper","replaceWith","getSuperCallsVisitor","CallExpression","child","allSuperCalls","isSuper","arrowParent","thisEnvFn","findParent","p","isProgram","isClassProperty","static","isClassPrivateProperty","inConstructor","isClassMethod","kind","thisPaths","argumentsPaths","newTargetPaths","superProps","superCalls","getScopeInformation","length","traverse","superBinding","getSuperBinding","forEach","superCall","callee","loc","argumentsBinding","getBinding","args","buildUndefinedNode","argumentsChild","argsRef","newTargetBinding","targetChild","targetRef","flatSuperProps","reduce","acc","superProp","concat","standardizeSuperProperty","superParentPath","isAssignment","isAssignmentExpression","left","isCall","isCallExpression","isTaggedTemplate","isTaggedTemplateExpression","tag","getSuperPropBinding","value","right","call","getThisBinding","hasSuperClass","thisChild","thisRef","isJSX","isLogicalOp","op","includes","operator","assignmentPath","slice","isLogicalAssignment","tmp","generateDeclaredUidIdentifier","object","rightExpression","isUpdateExpression","updateExpr","computedKey","parts","prefix","superClass","assignSuperThisVisitor","supers","has","add","replaceWithMultiple","WeakSet","argsBinding","propName","argsList","fnBody","method","unshift","valueIdent","cacheKey","data","getData","setData","getScopeInformationVisitor","ThisExpression","JSXIdentifier","isJSXMemberExpression","isJSXOpeningElement","MemberExpression","Identifier","isReferencedIdentifier","curr","hasOwnBinding","rename","parent","MetaProperty"],"sources":["../../src/path/conversion.ts"],"sourcesContent":["// This file contains methods that convert the path node into another node or some other type of data.\n\nimport {\n arrowFunctionExpression,\n assignmentExpression,\n binaryExpression,\n blockStatement,\n callExpression,\n conditionalExpression,\n expressionStatement,\n identifier,\n isIdentifier,\n jsxIdentifier,\n logicalExpression,\n LOGICAL_OPERATORS,\n memberExpression,\n metaProperty,\n numericLiteral,\n objectExpression,\n restElement,\n returnStatement,\n sequenceExpression,\n spreadElement,\n stringLiteral,\n super as _super,\n thisExpression,\n toExpression,\n unaryExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport environmentVisitor from \"@babel/helper-environment-visitor\";\nimport nameFunction from \"@babel/helper-function-name\";\nimport { merge as mergeVisitors } from \"../visitors\";\nimport type NodePath from \"./index\";\n\nexport function toComputedKey(this: NodePath) {\n let key;\n if (this.isMemberExpression()) {\n key = this.node.property;\n } else if (this.isProperty() || this.isMethod()) {\n key = this.node.key;\n } else {\n throw new ReferenceError(\"todo\");\n }\n\n // @ts-expect-error todo(flow->ts) computed does not exist in ClassPrivateProperty\n if (!this.node.computed) {\n if (isIdentifier(key)) key = stringLiteral(key.name);\n }\n\n return key;\n}\n\nexport function ensureBlock(\n this: NodePath<\n t.Loop | t.WithStatement | t.Function | t.LabeledStatement | t.CatchClause\n >,\n) {\n const body = this.get(\"body\");\n const bodyNode = body.node;\n\n if (Array.isArray(body)) {\n throw new Error(\"Can't convert array path to a block statement\");\n }\n if (!bodyNode) {\n throw new Error(\"Can't convert node without a body\");\n }\n\n if (body.isBlockStatement()) {\n return bodyNode;\n }\n\n const statements: Array<t.Statement> = [];\n\n let stringPath = \"body\";\n let key;\n let listKey;\n if (body.isStatement()) {\n listKey = \"body\";\n key = 0;\n statements.push(body.node);\n } else {\n stringPath += \".body.0\";\n if (this.isFunction()) {\n key = \"argument\";\n statements.push(returnStatement(body.node as t.Expression));\n } else {\n key = \"expression\";\n statements.push(expressionStatement(body.node as t.Expression));\n }\n }\n\n this.node.body = blockStatement(statements);\n const parentPath = this.get(stringPath) as NodePath;\n body.setup(\n parentPath,\n listKey\n ? // @ts-expect-error listKey must present in parent path\n parentPath.node[listKey]\n : parentPath.node,\n listKey,\n key,\n );\n\n return this.node;\n}\n\nif (!process.env.BABEL_8_BREAKING) {\n if (!USE_ESM) {\n /**\n * Keeping this for backward-compatibility. You should use arrowFunctionToExpression() for >=7.x.\n */\n // eslint-disable-next-line no-restricted-globals\n exports.arrowFunctionToShadowed = function (this: NodePath) {\n if (!this.isArrowFunctionExpression()) return;\n\n this.arrowFunctionToExpression();\n };\n }\n}\n\n/**\n * Given an arbitrary function, process its content as if it were an arrow function, moving references\n * to \"this\", \"arguments\", \"super\", and such into the function's parent scope. This method is useful if\n * you have wrapped some set of items in an IIFE or other function, but want \"this\", \"arguments\", and super\"\n * to continue behaving as expected.\n */\nexport function unwrapFunctionEnvironment(this: NodePath) {\n if (\n !this.isArrowFunctionExpression() &&\n !this.isFunctionExpression() &&\n !this.isFunctionDeclaration()\n ) {\n throw this.buildCodeFrameError(\n \"Can only unwrap the environment of a function.\",\n );\n }\n\n hoistFunctionEnvironment(this);\n}\n\nfunction setType<N extends t.Node, T extends N[\"type\"]>(\n path: NodePath<N>,\n type: T,\n): asserts path is NodePath<Extract<N, { type: T }>> {\n path.node.type = type;\n}\n\n/**\n * Convert a given arrow function into a normal ES5 function expression.\n */\nexport function arrowFunctionToExpression(\n this: NodePath<t.ArrowFunctionExpression>,\n {\n allowInsertArrow = true,\n allowInsertArrowWithRest = allowInsertArrow,\n noNewArrows = process.env.BABEL_8_BREAKING\n ? // TODO(Babel 8): Consider defaulting to `false` for spec compliance\n true\n : !arguments[0]?.specCompliant,\n }: {\n allowInsertArrow?: boolean | void;\n allowInsertArrowWithRest?: boolean | void;\n noNewArrows?: boolean;\n } = {},\n): NodePath<\n Exclude<t.Function, t.Method | t.ArrowFunctionExpression> | t.CallExpression\n> {\n if (!this.isArrowFunctionExpression()) {\n throw (this as NodePath).buildCodeFrameError(\n \"Cannot convert non-arrow function to a function expression.\",\n );\n }\n\n const { thisBinding, fnPath: fn } = hoistFunctionEnvironment(\n this,\n noNewArrows,\n allowInsertArrow,\n allowInsertArrowWithRest,\n );\n\n // @ts-expect-error TS requires explicit fn type annotation\n fn.ensureBlock();\n setType(fn, \"FunctionExpression\");\n\n if (!noNewArrows) {\n const checkBinding = thisBinding\n ? null\n : fn.scope.generateUidIdentifier(\"arrowCheckId\");\n if (checkBinding) {\n fn.parentPath.scope.push({\n id: checkBinding,\n init: objectExpression([]),\n });\n }\n\n fn.get(\"body\").unshiftContainer(\n \"body\",\n expressionStatement(\n callExpression(this.hub.addHelper(\"newArrowCheck\"), [\n thisExpression(),\n checkBinding\n ? identifier(checkBinding.name)\n : identifier(thisBinding),\n ]),\n ),\n );\n\n fn.replaceWith(\n callExpression(\n memberExpression(\n // @ts-expect-error TS can't infer nameFunction returns CallExpression | ArrowFunctionExpression here\n nameFunction(this, true) || fn.node,\n identifier(\"bind\"),\n ),\n [checkBinding ? identifier(checkBinding.name) : thisExpression()],\n ),\n );\n\n return fn.get(\"callee.object\");\n }\n\n return fn;\n}\n\nconst getSuperCallsVisitor = mergeVisitors<{\n allSuperCalls: NodePath<t.CallExpression>[];\n}>([\n {\n CallExpression(child, { allSuperCalls }) {\n if (!child.get(\"callee\").isSuper()) return;\n allSuperCalls.push(child);\n },\n },\n environmentVisitor,\n]);\n\n/**\n * Given a function, traverse its contents, and if there are references to \"this\", \"arguments\", \"super\",\n * or \"new.target\", ensure that these references reference the parent environment around this function.\n *\n * @returns `thisBinding`: the name of the injected reference to `this`; for example \"_this\"\n * @returns `fnPath`: the new path to the function node. This is different from the fnPath\n * parameter when the function node is wrapped in another node.\n */\nfunction hoistFunctionEnvironment(\n fnPath: NodePath<t.Function>,\n // TODO(Babel 8): Consider defaulting to `false` for spec compliance\n noNewArrows: boolean | void = true,\n allowInsertArrow: boolean | void = true,\n allowInsertArrowWithRest: boolean | void = true,\n): { thisBinding: string; fnPath: NodePath<t.Function> } {\n let arrowParent;\n let thisEnvFn: NodePath<t.Function> = fnPath.findParent(p => {\n if (p.isArrowFunctionExpression()) {\n arrowParent ??= p;\n return false;\n }\n return (\n p.isFunction() ||\n p.isProgram() ||\n p.isClassProperty({ static: false }) ||\n p.isClassPrivateProperty({ static: false })\n );\n }) as NodePath<t.Function>;\n const inConstructor = thisEnvFn.isClassMethod({ kind: \"constructor\" });\n\n if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) {\n if (arrowParent) {\n thisEnvFn = arrowParent;\n } else if (allowInsertArrow) {\n // It's safe to wrap this function in another and not hoist to the\n // top level because the 'this' binding is constant in class\n // properties (since 'super()' has already been called), so we don't\n // need to capture/reassign it at the top level.\n fnPath.replaceWith(\n callExpression(\n arrowFunctionExpression([], toExpression(fnPath.node)),\n [],\n ),\n );\n thisEnvFn = fnPath.get(\"callee\") as NodePath<t.ArrowFunctionExpression>;\n fnPath = thisEnvFn.get(\"body\") as NodePath<t.FunctionExpression>;\n } else {\n throw fnPath.buildCodeFrameError(\n \"Unable to transform arrow inside class property\",\n );\n }\n }\n\n const { thisPaths, argumentsPaths, newTargetPaths, superProps, superCalls } =\n getScopeInformation(fnPath);\n\n // Convert all super() calls in the constructor, if super is used in an arrow.\n if (inConstructor && superCalls.length > 0) {\n if (!allowInsertArrow) {\n throw superCalls[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-arrow-functions', \" +\n \"it's not possible to compile `super()` in an arrow function without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n if (!allowInsertArrowWithRest) {\n // preset-env with target `since 2017` enables `transform-parameters` without `transform-classes`.\n throw superCalls[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-parameters', \" +\n \"it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n const allSuperCalls: NodePath<t.CallExpression>[] = [];\n thisEnvFn.traverse(getSuperCallsVisitor, { allSuperCalls });\n const superBinding = getSuperBinding(thisEnvFn);\n allSuperCalls.forEach(superCall => {\n const callee = identifier(superBinding);\n callee.loc = superCall.node.callee.loc;\n\n superCall.get(\"callee\").replaceWith(callee);\n });\n }\n\n // Convert all \"arguments\" references in the arrow to point at the alias.\n if (argumentsPaths.length > 0) {\n const argumentsBinding = getBinding(thisEnvFn, \"arguments\", () => {\n const args = () => identifier(\"arguments\");\n if (thisEnvFn.scope.path.isProgram()) {\n return conditionalExpression(\n binaryExpression(\n \"===\",\n unaryExpression(\"typeof\", args()),\n stringLiteral(\"undefined\"),\n ),\n thisEnvFn.scope.buildUndefinedNode(),\n args(),\n );\n } else {\n return args();\n }\n });\n\n argumentsPaths.forEach(argumentsChild => {\n const argsRef = identifier(argumentsBinding);\n argsRef.loc = argumentsChild.node.loc;\n\n argumentsChild.replaceWith(argsRef);\n });\n }\n\n // Convert all \"new.target\" references in the arrow to point at the alias.\n if (newTargetPaths.length > 0) {\n const newTargetBinding = getBinding(thisEnvFn, \"newtarget\", () =>\n metaProperty(identifier(\"new\"), identifier(\"target\")),\n );\n\n newTargetPaths.forEach(targetChild => {\n const targetRef = identifier(newTargetBinding);\n targetRef.loc = targetChild.node.loc;\n\n targetChild.replaceWith(targetRef);\n });\n }\n\n // Convert all \"super.prop\" references to point at aliases.\n if (superProps.length > 0) {\n if (!allowInsertArrow) {\n throw superProps[0].buildCodeFrameError(\n \"When using '@babel/plugin-transform-arrow-functions', \" +\n \"it's not possible to compile `super.prop` in an arrow function without compiling classes.\\n\" +\n \"Please add '@babel/plugin-transform-classes' to your Babel configuration.\",\n );\n }\n\n const flatSuperProps: NodePath<t.MemberExpression>[] = superProps.reduce(\n (acc, superProp) => acc.concat(standardizeSuperProperty(superProp)),\n [],\n );\n\n flatSuperProps.forEach(superProp => {\n const key = superProp.node.computed\n ? \"\"\n : // @ts-expect-error super property must not contain private name\n superProp.get(\"property\").node.name;\n\n const superParentPath = superProp.parentPath;\n\n const isAssignment = superParentPath.isAssignmentExpression({\n left: superProp.node,\n });\n const isCall = superParentPath.isCallExpression({\n callee: superProp.node,\n });\n const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({\n tag: superProp.node,\n });\n const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);\n\n const args: t.Expression[] = [];\n if (superProp.node.computed) {\n // SuperProperty must not be a private name\n args.push(superProp.get(\"property\").node as t.Expression);\n }\n\n if (isAssignment) {\n const value = superParentPath.node.right;\n args.push(value);\n }\n\n const call = callExpression(identifier(superBinding), args);\n\n if (isCall) {\n superParentPath.unshiftContainer(\"arguments\", thisExpression());\n superProp.replaceWith(memberExpression(call, identifier(\"call\")));\n\n thisPaths.push(\n superParentPath.get(\"arguments.0\") as NodePath<t.ThisExpression>,\n );\n } else if (isAssignment) {\n // Replace not only the super.prop, but the whole assignment\n superParentPath.replaceWith(call);\n } else if (isTaggedTemplate) {\n superProp.replaceWith(\n callExpression(memberExpression(call, identifier(\"bind\"), false), [\n thisExpression(),\n ]),\n );\n\n thisPaths.push(\n superProp.get(\"arguments.0\") as NodePath<t.ThisExpression>,\n );\n } else {\n superProp.replaceWith(call);\n }\n });\n }\n\n // Convert all \"this\" references in the arrow to point at the alias.\n let thisBinding: string | null;\n if (thisPaths.length > 0 || !noNewArrows) {\n thisBinding = getThisBinding(thisEnvFn, inConstructor);\n\n if (\n noNewArrows ||\n // In subclass constructors, still need to rewrite because \"this\" can't be bound in spec mode\n // because it might not have been initialized yet.\n (inConstructor && hasSuperClass(thisEnvFn))\n ) {\n thisPaths.forEach(thisChild => {\n const thisRef = thisChild.isJSX()\n ? jsxIdentifier(thisBinding)\n : identifier(thisBinding);\n\n thisRef.loc = thisChild.node.loc;\n thisChild.replaceWith(thisRef);\n });\n\n if (!noNewArrows) thisBinding = null;\n }\n }\n\n return { thisBinding, fnPath };\n}\n\ntype LogicalOp = Parameters<typeof logicalExpression>[0];\ntype BinaryOp = Parameters<typeof binaryExpression>[0];\n\nfunction isLogicalOp(op: string): op is LogicalOp {\n return LOGICAL_OPERATORS.includes(op);\n}\n\nfunction standardizeSuperProperty(\n superProp: NodePath<t.MemberExpression>,\n):\n | [NodePath<t.MemberExpression>]\n | [NodePath<t.MemberExpression>, NodePath<t.MemberExpression>] {\n if (\n superProp.parentPath.isAssignmentExpression() &&\n superProp.parentPath.node.operator !== \"=\"\n ) {\n const assignmentPath = superProp.parentPath;\n\n const op = assignmentPath.node.operator.slice(0, -1) as\n | LogicalOp\n | BinaryOp;\n\n const value = assignmentPath.node.right;\n\n const isLogicalAssignment = isLogicalOp(op);\n\n if (superProp.node.computed) {\n // from: super[foo] **= 4;\n // to: super[tmp = foo] = super[tmp] ** 4;\n\n // from: super[foo] ??= 4;\n // to: super[tmp = foo] ?? super[tmp] = 4;\n\n const tmp = superProp.scope.generateDeclaredUidIdentifier(\"tmp\");\n\n const object = superProp.node.object;\n const property = superProp.node.property as t.Expression;\n\n assignmentPath\n .get(\"left\")\n .replaceWith(\n memberExpression(\n object,\n assignmentExpression(\"=\", tmp, property),\n true /* computed */,\n ),\n );\n\n assignmentPath\n .get(\"right\")\n .replaceWith(\n rightExpression(\n isLogicalAssignment ? \"=\" : op,\n memberExpression(object, identifier(tmp.name), true /* computed */),\n value,\n ),\n );\n } else {\n // from: super.foo **= 4;\n // to: super.foo = super.foo ** 4;\n\n // from: super.foo ??= 4;\n // to: super.foo ?? super.foo = 4;\n\n const object = superProp.node.object;\n const property = superProp.node.property as t.Identifier;\n\n assignmentPath\n .get(\"left\")\n .replaceWith(memberExpression(object, property));\n\n assignmentPath\n .get(\"right\")\n .replaceWith(\n rightExpression(\n isLogicalAssignment ? \"=\" : op,\n memberExpression(object, identifier(property.name)),\n value,\n ),\n );\n }\n\n if (isLogicalAssignment) {\n assignmentPath.replaceWith(\n logicalExpression(\n op,\n assignmentPath.node.left as t.MemberExpression,\n assignmentPath.node.right,\n ),\n );\n } else {\n assignmentPath.node.operator = \"=\";\n }\n\n return [\n assignmentPath.get(\"left\") as NodePath<t.MemberExpression>,\n assignmentPath.get(\"right\").get(\"left\"),\n ];\n } else if (superProp.parentPath.isUpdateExpression()) {\n const updateExpr = superProp.parentPath;\n\n const tmp = superProp.scope.generateDeclaredUidIdentifier(\"tmp\");\n const computedKey = superProp.node.computed\n ? superProp.scope.generateDeclaredUidIdentifier(\"prop\")\n : null;\n\n const parts: t.Expression[] = [\n assignmentExpression(\n \"=\",\n tmp,\n memberExpression(\n superProp.node.object,\n computedKey\n ? assignmentExpression(\n \"=\",\n computedKey,\n superProp.node.property as t.Expression,\n )\n : superProp.node.property,\n superProp.node.computed,\n ),\n ),\n assignmentExpression(\n \"=\",\n memberExpression(\n superProp.node.object,\n computedKey ? identifier(computedKey.name) : superProp.node.property,\n superProp.node.computed,\n ),\n binaryExpression(\n // map `++` to `+`, and `--` to `-`\n superProp.parentPath.node.operator[0] as \"+\" | \"-\",\n identifier(tmp.name),\n numericLiteral(1),\n ),\n ),\n ];\n\n if (!superProp.parentPath.node.prefix) {\n parts.push(identifier(tmp.name));\n }\n\n updateExpr.replaceWith(sequenceExpression(parts));\n\n const left = updateExpr.get(\n \"expressions.0.right\",\n ) as NodePath<t.MemberExpression>;\n const right = updateExpr.get(\n \"expressions.1.left\",\n ) as NodePath<t.MemberExpression>;\n return [left, right];\n }\n\n return [superProp];\n\n function rightExpression(\n op: BinaryOp | \"=\",\n left: t.MemberExpression,\n right: t.Expression,\n ) {\n if (op === \"=\") {\n return assignmentExpression(\"=\", left, right);\n } else {\n return binaryExpression(op, left, right);\n }\n }\n}\n\nfunction hasSuperClass(thisEnvFn: NodePath<t.Function>) {\n return (\n thisEnvFn.isClassMethod() &&\n !!(thisEnvFn.parentPath.parentPath.node as t.Class).superClass\n );\n}\n\nconst assignSuperThisVisitor = mergeVisitors<{\n supers: WeakSet<t.CallExpression>;\n thisBinding: string;\n}>([\n {\n CallExpression(child, { supers, thisBinding }) {\n if (!child.get(\"callee\").isSuper()) return;\n if (supers.has(child.node)) return;\n supers.add(child.node);\n\n child.replaceWithMultiple([\n child.node,\n assignmentExpression(\"=\", identifier(thisBinding), identifier(\"this\")),\n ]);\n },\n },\n environmentVisitor,\n]);\n\n// Create a binding that evaluates to the \"this\" of the given function.\nfunction getThisBinding(\n thisEnvFn: NodePath<t.Function>,\n inConstructor: boolean,\n) {\n return getBinding(thisEnvFn, \"this\", thisBinding => {\n if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();\n\n thisEnvFn.traverse(assignSuperThisVisitor, {\n supers: new WeakSet(),\n thisBinding,\n });\n });\n}\n\n// Create a binding for a function that will call \"super()\" with arguments passed through.\nfunction getSuperBinding(thisEnvFn: NodePath<t.Function>) {\n return getBinding(thisEnvFn, \"supercall\", () => {\n const argsBinding = thisEnvFn.scope.generateUidIdentifier(\"args\");\n return arrowFunctionExpression(\n [restElement(argsBinding)],\n callExpression(_super(), [spreadElement(identifier(argsBinding.name))]),\n );\n });\n}\n\n// Create a binding for a function that will call \"super.foo\" or \"super[foo]\".\nfunction getSuperPropBinding(\n thisEnvFn: NodePath<t.Function>,\n isAssignment: boolean,\n propName: string,\n) {\n const op = isAssignment ? \"set\" : \"get\";\n\n return getBinding(thisEnvFn, `superprop_${op}:${propName || \"\"}`, () => {\n const argsList = [];\n\n let fnBody;\n if (propName) {\n // () => super.foo\n fnBody = memberExpression(_super(), identifier(propName));\n } else {\n const method = thisEnvFn.scope.generateUidIdentifier(\"prop\");\n // (method) => super[method]\n argsList.unshift(method);\n fnBody = memberExpression(\n _super(),\n identifier(method.name),\n true /* computed */,\n );\n }\n\n if (isAssignment) {\n const valueIdent = thisEnvFn.scope.generateUidIdentifier(\"value\");\n argsList.push(valueIdent);\n\n fnBody = assignmentExpression(\"=\", fnBody, identifier(valueIdent.name));\n }\n\n return arrowFunctionExpression(argsList, fnBody);\n });\n}\n\nfunction getBinding(\n thisEnvFn: NodePath,\n key: string,\n init: (name: string) => t.Expression,\n) {\n const cacheKey = \"binding:\" + key;\n let data: string | undefined = thisEnvFn.getData(cacheKey);\n if (!data) {\n const id = thisEnvFn.scope.generateUidIdentifier(key);\n data = id.name;\n thisEnvFn.setData(cacheKey, data);\n\n thisEnvFn.scope.push({\n id: id,\n init: init(data),\n });\n }\n\n return data;\n}\n\ntype ScopeInfo = {\n thisPaths: NodePath<t.ThisExpression | t.JSXIdentifier>[];\n superCalls: NodePath<t.CallExpression>[];\n superProps: NodePath<t.MemberExpression>[];\n argumentsPaths: NodePath<t.Identifier | t.JSXIdentifier>[];\n newTargetPaths: NodePath<t.MetaProperty>[];\n};\n\nconst getScopeInformationVisitor = mergeVisitors<ScopeInfo>([\n {\n ThisExpression(child, { thisPaths }) {\n thisPaths.push(child);\n },\n JSXIdentifier(child, { thisPaths }) {\n if (child.node.name !== \"this\") return;\n if (\n !child.parentPath.isJSXMemberExpression({ object: child.node }) &&\n !child.parentPath.isJSXOpeningElement({ name: child.node })\n ) {\n return;\n }\n\n thisPaths.push(child);\n },\n CallExpression(child, { superCalls }) {\n if (child.get(\"callee\").isSuper()) superCalls.push(child);\n },\n MemberExpression(child, { superProps }) {\n if (child.get(\"object\").isSuper()) superProps.push(child);\n },\n Identifier(child, { argumentsPaths }) {\n if (!child.isReferencedIdentifier({ name: \"arguments\" })) return;\n\n let curr = child.scope;\n do {\n if (curr.hasOwnBinding(\"arguments\")) {\n curr.rename(\"arguments\");\n return;\n }\n if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {\n break;\n }\n } while ((curr = curr.parent));\n\n argumentsPaths.push(child);\n },\n MetaProperty(child, { newTargetPaths }) {\n if (!child.get(\"meta\").isIdentifier({ name: \"new\" })) return;\n if (!child.get(\"property\").isIdentifier({ name: \"target\" })) return;\n\n newTargetPaths.push(child);\n },\n },\n environmentVisitor,\n]);\n\nfunction getScopeInformation(fnPath: NodePath) {\n const thisPaths: ScopeInfo[\"thisPaths\"] = [];\n const argumentsPaths: ScopeInfo[\"argumentsPaths\"] = [];\n const newTargetPaths: ScopeInfo[\"newTargetPaths\"] = [];\n const superProps: ScopeInfo[\"superProps\"] = [];\n const superCalls: ScopeInfo[\"superCalls\"] = [];\n\n fnPath.traverse(getScopeInformationVisitor, {\n thisPaths,\n argumentsPaths,\n newTargetPaths,\n superProps,\n superCalls,\n });\n\n return {\n thisPaths,\n argumentsPaths,\n newTargetPaths,\n superProps,\n superCalls,\n };\n}\n"],"mappings":"AAEA,YAAAA,EAAA,MA0BO,cAAc;AAAC;EAzBpBC,uBAAuB;EACvBC,oBAAoB;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,qBAAqB;EACrBC,mBAAmB;EACnBC,UAAU;EACVC,YAAY;EACZC,aAAa;EACbC,iBAAiB;EACjBC,iBAAiB;EACjBC,gBAAgB;EAChBC,YAAY;EACZC,cAAc;EACdC,gBAAgB;EAChBC,WAAW;EACXC,eAAe;EACfC,kBAAkB;EAClBC,aAAa;EACbC,aAAa;EACbC,KAAK,EAAIC,MAAM;EACfC,cAAc;EACdC,YAAY;EACZC;AAAe,IAAA1B,EAAA;AAGjB,OAAO2B,kBAAkB,MAAM,mCAAmC;AAClE,OAAOC,YAAY,MAAM,6BAA6B;AACtD,SAASC,KAAK,IAAIC,aAAa,QAAQ,gBAAa;AAGpD,OAAO,SAASC,aAAaA,CAAA,EAAiB;EAC5C,IAAIC,GAAG;EACP,IAAI,IAAI,CAACC,kBAAkB,CAAC,CAAC,EAAE;IAC7BD,GAAG,GAAG,IAAI,CAACE,IAAI,CAACC,QAAQ;EAC1B,CAAC,MAAM,IAAI,IAAI,CAACC,UAAU,CAAC,CAAC,IAAI,IAAI,CAACC,QAAQ,CAAC,CAAC,EAAE;IAC/CL,GAAG,GAAG,IAAI,CAACE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