@babel/traverse 7.14.9 → 7.16.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.

Potentially problematic release.


This version of @babel/traverse might be problematic. Click here for more details.

package/lib/context.js CHANGED
@@ -7,7 +7,11 @@ exports.default = void 0;
7
7
 
8
8
  var _path = require("./path");
9
9
 
10
- var t = require("@babel/types");
10
+ var _t = require("@babel/types");
11
+
12
+ const {
13
+ VISITOR_KEYS
14
+ } = _t;
11
15
 
12
16
  class TraversalContext {
13
17
  constructor(scope, opts, state, parentPath) {
@@ -23,7 +27,7 @@ class TraversalContext {
23
27
  const opts = this.opts;
24
28
  if (opts.enter || opts.exit) return true;
25
29
  if (opts[node.type]) return true;
26
- const keys = t.VISITOR_KEYS[node.type];
30
+ const keys = VISITOR_KEYS[node.type];
27
31
  if (!(keys != null && keys.length)) return false;
28
32
 
29
33
  for (const key of keys) {
package/lib/index.js CHANGED
@@ -3,22 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "NodePath", {
6
+ Object.defineProperty(exports, "Hub", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _path.default;
9
+ return _hub.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Scope", {
12
+ Object.defineProperty(exports, "NodePath", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _scope.default;
15
+ return _path.default;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "Hub", {
18
+ Object.defineProperty(exports, "Scope", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _hub.default;
21
+ return _scope.default;
22
22
  }
23
23
  });
24
24
  exports.visitors = exports.default = void 0;
@@ -29,7 +29,7 @@ var visitors = require("./visitors");
29
29
 
30
30
  exports.visitors = visitors;
31
31
 
32
- var t = require("@babel/types");
32
+ var _t = require("@babel/types");
33
33
 
34
34
  var cache = require("./cache");
35
35
 
@@ -39,6 +39,12 @@ var _scope = require("./scope");
39
39
 
40
40
  var _hub = require("./hub");
41
41
 
42
+ const {
43
+ VISITOR_KEYS,
44
+ removeProperties,
45
+ traverseFast
46
+ } = _t;
47
+
42
48
  function traverse(parent, opts = {}, scope, state, parentPath) {
43
49
  if (!parent) return;
44
50
 
@@ -48,7 +54,7 @@ function traverse(parent, opts = {}, scope, state, parentPath) {
48
54
  }
49
55
  }
50
56
 
51
- if (!t.VISITOR_KEYS[parent.type]) {
57
+ if (!VISITOR_KEYS[parent.type]) {
52
58
  return;
53
59
  }
54
60
 
@@ -63,11 +69,11 @@ traverse.verify = visitors.verify;
63
69
  traverse.explode = visitors.explode;
64
70
 
65
71
  traverse.cheap = function (node, enter) {
66
- return t.traverseFast(node, enter);
72
+ return traverseFast(node, enter);
67
73
  };
68
74
 
69
75
  traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
70
- const keys = t.VISITOR_KEYS[node.type];
76
+ const keys = VISITOR_KEYS[node.type];
71
77
  if (!keys) return;
72
78
  const context = new _context.default(scope, opts, state, parentPath);
73
79
 
@@ -78,12 +84,12 @@ traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
78
84
  };
79
85
 
80
86
  traverse.clearNode = function (node, opts) {
81
- t.removeProperties(node, opts);
87
+ removeProperties(node, opts);
82
88
  cache.path.delete(node);
83
89
  };
84
90
 
85
91
  traverse.removeProperties = function (tree, opts) {
86
- t.traverseFast(tree, traverse.clearNode, opts);
92
+ traverseFast(tree, traverse.clearNode, opts);
87
93
  return tree;
88
94
  };
89
95
 
@@ -3,21 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.findParent = findParent;
7
6
  exports.find = find;
7
+ exports.findParent = findParent;
8
+ exports.getAncestry = getAncestry;
9
+ exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
10
+ exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
8
11
  exports.getFunctionParent = getFunctionParent;
9
12
  exports.getStatementParent = getStatementParent;
10
- exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
11
- exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
12
- exports.getAncestry = getAncestry;
13
+ exports.inType = inType;
13
14
  exports.isAncestor = isAncestor;
14
15
  exports.isDescendant = isDescendant;
15
- exports.inType = inType;
16
16
 
17
- var t = require("@babel/types");
17
+ var _t = require("@babel/types");
18
18
 
19
19
  var _index = require("./index");
20
20
 
21
+ const {
22
+ VISITOR_KEYS
23
+ } = _t;
24
+
21
25
  function findParent(callback) {
22
26
  let path = this;
23
27
 
@@ -63,7 +67,7 @@ function getStatementParent() {
63
67
  function getEarliestCommonAncestorFrom(paths) {
64
68
  return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
65
69
  let earliest;
66
- const keys = t.VISITOR_KEYS[deepest.type];
70
+ const keys = VISITOR_KEYS[deepest.type];
67
71
 
68
72
  for (const ancestry of ancestries) {
69
73
  const path = ancestry[i + 1];
@@ -3,11 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
7
6
  exports.addComment = addComment;
8
7
  exports.addComments = addComments;
8
+ exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
9
+
10
+ var _t = require("@babel/types");
9
11
 
10
- var t = require("@babel/types");
12
+ const {
13
+ addComment: _addComment,
14
+ addComments: _addComments
15
+ } = _t;
11
16
 
12
17
  function shareCommentsWithSiblings() {
13
18
  if (typeof this.key === "string") return;
@@ -29,9 +34,9 @@ function shareCommentsWithSiblings() {
29
34
  }
30
35
 
31
36
  function addComment(type, content, line) {
32
- t.addComment(this.node, type, content, line);
37
+ _addComment(this.node, type, content, line);
33
38
  }
34
39
 
35
40
  function addComments(type, comments) {
36
- t.addComments(this.node, type, comments);
41
+ _addComments(this.node, type, comments);
37
42
  }
@@ -3,26 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.call = call;
7
6
  exports._call = _call;
8
- exports.isBlacklisted = exports.isDenylisted = isDenylisted;
9
- exports.visit = visit;
10
- exports.skip = skip;
11
- exports.skipKey = skipKey;
12
- exports.stop = stop;
13
- exports.setScope = setScope;
14
- exports.setContext = setContext;
15
- exports.resync = resync;
16
- exports._resyncParent = _resyncParent;
7
+ exports._getQueueContexts = _getQueueContexts;
17
8
  exports._resyncKey = _resyncKey;
18
9
  exports._resyncList = _resyncList;
10
+ exports._resyncParent = _resyncParent;
19
11
  exports._resyncRemoved = _resyncRemoved;
12
+ exports.call = call;
13
+ exports.isBlacklisted = exports.isDenylisted = isDenylisted;
20
14
  exports.popContext = popContext;
21
15
  exports.pushContext = pushContext;
22
- exports.setup = setup;
23
- exports.setKey = setKey;
24
16
  exports.requeue = requeue;
25
- exports._getQueueContexts = _getQueueContexts;
17
+ exports.resync = resync;
18
+ exports.setContext = setContext;
19
+ exports.setKey = setKey;
20
+ exports.setScope = setScope;
21
+ exports.setup = setup;
22
+ exports.skip = skip;
23
+ exports.skipKey = skipKey;
24
+ exports.stop = stop;
25
+ exports.visit = visit;
26
26
 
27
27
  var _index = require("../index");
28
28
 
@@ -74,6 +74,14 @@ function isDenylisted() {
74
74
  return denylist && denylist.indexOf(this.node.type) > -1;
75
75
  }
76
76
 
77
+ function restoreContext(path, context) {
78
+ if (path.context !== context) {
79
+ path.context = context;
80
+ path.state = context.state;
81
+ path.opts = context.opts;
82
+ }
83
+ }
84
+
77
85
  function visit() {
78
86
  if (!this.node) {
79
87
  return false;
@@ -87,15 +95,19 @@ function visit() {
87
95
  return false;
88
96
  }
89
97
 
90
- if (this.shouldSkip || this.call("enter") || this.shouldSkip) {
98
+ const currentContext = this.context;
99
+
100
+ if (this.shouldSkip || this.call("enter")) {
91
101
  this.debug("Skip...");
92
102
  return this.shouldStop;
93
103
  }
94
104
 
105
+ restoreContext(this, currentContext);
95
106
  this.debug("Recursing into...");
96
107
 
97
108
  _index.default.node(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
98
109
 
110
+ restoreContext(this, currentContext);
99
111
  this.call("exit");
100
112
  return this.shouldStop;
101
113
  }
@@ -3,16 +3,42 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toComputedKey = toComputedKey;
7
- exports.ensureBlock = ensureBlock;
6
+ exports.arrowFunctionToExpression = arrowFunctionToExpression;
8
7
  exports.arrowFunctionToShadowed = arrowFunctionToShadowed;
8
+ exports.ensureBlock = ensureBlock;
9
+ exports.toComputedKey = toComputedKey;
9
10
  exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
10
- exports.arrowFunctionToExpression = arrowFunctionToExpression;
11
11
 
12
- var t = require("@babel/types");
12
+ var _t = require("@babel/types");
13
13
 
14
14
  var _helperFunctionName = require("@babel/helper-function-name");
15
15
 
16
+ const {
17
+ arrowFunctionExpression,
18
+ assignmentExpression,
19
+ binaryExpression,
20
+ blockStatement,
21
+ callExpression,
22
+ conditionalExpression,
23
+ expressionStatement,
24
+ identifier,
25
+ isIdentifier,
26
+ jsxIdentifier,
27
+ memberExpression,
28
+ metaProperty,
29
+ numericLiteral,
30
+ objectExpression,
31
+ restElement,
32
+ returnStatement,
33
+ sequenceExpression,
34
+ spreadElement,
35
+ stringLiteral,
36
+ super: _super,
37
+ thisExpression,
38
+ toExpression,
39
+ unaryExpression
40
+ } = _t;
41
+
16
42
  function toComputedKey() {
17
43
  let key;
18
44
 
@@ -25,7 +51,7 @@ function toComputedKey() {
25
51
  }
26
52
 
27
53
  if (!this.node.computed) {
28
- if (t.isIdentifier(key)) key = t.stringLiteral(key.name);
54
+ if (isIdentifier(key)) key = stringLiteral(key.name);
29
55
  }
30
56
 
31
57
  return key;
@@ -61,14 +87,14 @@ function ensureBlock() {
61
87
 
62
88
  if (this.isFunction()) {
63
89
  key = "argument";
64
- statements.push(t.returnStatement(body.node));
90
+ statements.push(returnStatement(body.node));
65
91
  } else {
66
92
  key = "expression";
67
- statements.push(t.expressionStatement(body.node));
93
+ statements.push(expressionStatement(body.node));
68
94
  }
69
95
  }
70
96
 
71
- this.node.body = t.blockStatement(statements);
97
+ this.node.body = blockStatement(statements);
72
98
  const parentPath = this.get(stringPath);
73
99
  body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
74
100
  return this.node;
@@ -96,35 +122,58 @@ function arrowFunctionToExpression({
96
122
  throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
97
123
  }
98
124
 
99
- const thisBinding = hoistFunctionEnvironment(this, noNewArrows, allowInsertArrow);
100
- this.ensureBlock();
101
- this.node.type = "FunctionExpression";
125
+ const {
126
+ thisBinding,
127
+ fnPath: fn
128
+ } = hoistFunctionEnvironment(this, noNewArrows, allowInsertArrow);
129
+ fn.ensureBlock();
130
+ fn.node.type = "FunctionExpression";
102
131
 
103
132
  if (!noNewArrows) {
104
- const checkBinding = thisBinding ? null : this.parentPath.scope.generateUidIdentifier("arrowCheckId");
133
+ const checkBinding = thisBinding ? null : fn.scope.generateUidIdentifier("arrowCheckId");
105
134
 
106
135
  if (checkBinding) {
107
- this.parentPath.scope.push({
136
+ fn.parentPath.scope.push({
108
137
  id: checkBinding,
109
- init: t.objectExpression([])
138
+ init: objectExpression([])
110
139
  });
111
140
  }
112
141
 
113
- this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)])));
114
- this.replaceWith(t.callExpression(t.memberExpression((0, _helperFunctionName.default)(this, true) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
142
+ fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)])));
143
+ fn.replaceWith(callExpression(memberExpression((0, _helperFunctionName.default)(this, true) || fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()]));
115
144
  }
116
145
  }
117
146
 
118
147
  function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true) {
119
- const thisEnvFn = fnPath.findParent(p => {
120
- return p.isFunction() && !p.isArrowFunctionExpression() || p.isProgram() || p.isClassProperty({
148
+ let arrowParent;
149
+ let thisEnvFn = fnPath.findParent(p => {
150
+ if (p.isArrowFunctionExpression()) {
151
+ var _arrowParent;
152
+
153
+ (_arrowParent = arrowParent) != null ? _arrowParent : arrowParent = p;
154
+ return false;
155
+ }
156
+
157
+ return p.isFunction() || p.isProgram() || p.isClassProperty({
158
+ static: false
159
+ }) || p.isClassPrivateProperty({
121
160
  static: false
122
161
  });
123
162
  });
124
- const inConstructor = (thisEnvFn == null ? void 0 : thisEnvFn.node.kind) === "constructor";
163
+ const inConstructor = thisEnvFn.isClassMethod({
164
+ kind: "constructor"
165
+ });
125
166
 
126
- if (thisEnvFn.isClassProperty()) {
127
- throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
167
+ if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) {
168
+ if (arrowParent) {
169
+ thisEnvFn = arrowParent;
170
+ } else if (allowInsertArrow) {
171
+ fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), []));
172
+ thisEnvFn = fnPath.get("callee");
173
+ fnPath = thisEnvFn.get("body");
174
+ } else {
175
+ throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
176
+ }
128
177
  }
129
178
 
130
179
  const {
@@ -159,7 +208,7 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
159
208
  });
160
209
  const superBinding = getSuperBinding(thisEnvFn);
161
210
  allSuperCalls.forEach(superCall => {
162
- const callee = t.identifier(superBinding);
211
+ const callee = identifier(superBinding);
163
212
  callee.loc = superCall.node.callee.loc;
164
213
  superCall.get("callee").replaceWith(callee);
165
214
  });
@@ -167,25 +216,25 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
167
216
 
168
217
  if (argumentsPaths.length > 0) {
169
218
  const argumentsBinding = getBinding(thisEnvFn, "arguments", () => {
170
- const args = () => t.identifier("arguments");
219
+ const args = () => identifier("arguments");
171
220
 
172
221
  if (thisEnvFn.scope.path.isProgram()) {
173
- return t.conditionalExpression(t.binaryExpression("===", t.unaryExpression("typeof", args()), t.stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args());
222
+ return conditionalExpression(binaryExpression("===", unaryExpression("typeof", args()), stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args());
174
223
  } else {
175
224
  return args();
176
225
  }
177
226
  });
178
227
  argumentsPaths.forEach(argumentsChild => {
179
- const argsRef = t.identifier(argumentsBinding);
228
+ const argsRef = identifier(argumentsBinding);
180
229
  argsRef.loc = argumentsChild.node.loc;
181
230
  argumentsChild.replaceWith(argsRef);
182
231
  });
183
232
  }
184
233
 
185
234
  if (newTargetPaths.length > 0) {
186
- const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t.metaProperty(t.identifier("new"), t.identifier("target")));
235
+ const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => metaProperty(identifier("new"), identifier("target")));
187
236
  newTargetPaths.forEach(targetChild => {
188
- const targetRef = t.identifier(newTargetBinding);
237
+ const targetRef = identifier(newTargetBinding);
189
238
  targetRef.loc = targetChild.node.loc;
190
239
  targetChild.replaceWith(targetRef);
191
240
  });
@@ -217,11 +266,11 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
217
266
  args.push(value);
218
267
  }
219
268
 
220
- const call = t.callExpression(t.identifier(superBinding), args);
269
+ const call = callExpression(identifier(superBinding), args);
221
270
 
222
271
  if (isCall) {
223
- superProp.parentPath.unshiftContainer("arguments", t.thisExpression());
224
- superProp.replaceWith(t.memberExpression(call, t.identifier("call")));
272
+ superProp.parentPath.unshiftContainer("arguments", thisExpression());
273
+ superProp.replaceWith(memberExpression(call, identifier("call")));
225
274
  thisPaths.push(superProp.parentPath.get("arguments.0"));
226
275
  } else if (isAssignment) {
227
276
  superProp.parentPath.replaceWith(call);
@@ -238,7 +287,7 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
238
287
 
239
288
  if (noNewArrows || inConstructor && hasSuperClass(thisEnvFn)) {
240
289
  thisPaths.forEach(thisChild => {
241
- const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
290
+ const thisRef = thisChild.isJSX() ? jsxIdentifier(thisBinding) : identifier(thisBinding);
242
291
  thisRef.loc = thisChild.node.loc;
243
292
  thisChild.replaceWith(thisRef);
244
293
  });
@@ -246,7 +295,10 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
246
295
  }
247
296
  }
248
297
 
249
- return thisBinding;
298
+ return {
299
+ thisBinding,
300
+ fnPath
301
+ };
250
302
  }
251
303
 
252
304
  function standardizeSuperProperty(superProp) {
@@ -258,11 +310,11 @@ function standardizeSuperProperty(superProp) {
258
310
 
259
311
  if (superProp.node.computed) {
260
312
  const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
261
- assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, t.assignmentExpression("=", tmp, superProp.node.property), true));
262
- assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(tmp.name), true), value));
313
+ assignmentPath.get("left").replaceWith(memberExpression(superProp.node.object, assignmentExpression("=", tmp, superProp.node.property), true));
314
+ assignmentPath.get("right").replaceWith(binaryExpression(op, memberExpression(superProp.node.object, identifier(tmp.name), true), value));
263
315
  } else {
264
- assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, superProp.node.property));
265
- assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(superProp.node.property.name)), value));
316
+ assignmentPath.get("left").replaceWith(memberExpression(superProp.node.object, superProp.node.property));
317
+ assignmentPath.get("right").replaceWith(binaryExpression(op, memberExpression(superProp.node.object, identifier(superProp.node.property.name)), value));
266
318
  }
267
319
 
268
320
  return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
@@ -270,13 +322,13 @@ function standardizeSuperProperty(superProp) {
270
322
  const updateExpr = superProp.parentPath;
271
323
  const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
272
324
  const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
273
- const parts = [t.assignmentExpression("=", tmp, t.memberExpression(superProp.node.object, computedKey ? t.assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t.assignmentExpression("=", t.memberExpression(superProp.node.object, computedKey ? t.identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t.binaryExpression("+", t.identifier(tmp.name), t.numericLiteral(1)))];
325
+ 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("+", identifier(tmp.name), numericLiteral(1)))];
274
326
 
275
327
  if (!superProp.parentPath.node.prefix) {
276
- parts.push(t.identifier(tmp.name));
328
+ parts.push(identifier(tmp.name));
277
329
  }
278
330
 
279
- updateExpr.replaceWith(t.sequenceExpression(parts));
331
+ updateExpr.replaceWith(sequenceExpression(parts));
280
332
  const left = updateExpr.get("expressions.0.right");
281
333
  const right = updateExpr.get("expressions.1.left");
282
334
  return [left, right];
@@ -291,7 +343,7 @@ function hasSuperClass(thisEnvFn) {
291
343
 
292
344
  function getThisBinding(thisEnvFn, inConstructor) {
293
345
  return getBinding(thisEnvFn, "this", thisBinding => {
294
- if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
346
+ if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression();
295
347
  const supers = new WeakSet();
296
348
  thisEnvFn.traverse({
297
349
  Function(child) {
@@ -307,7 +359,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
307
359
  if (!child.get("callee").isSuper()) return;
308
360
  if (supers.has(child.node)) return;
309
361
  supers.add(child.node);
310
- child.replaceWithMultiple([child.node, t.assignmentExpression("=", t.identifier(thisBinding), t.identifier("this"))]);
362
+ child.replaceWithMultiple([child.node, assignmentExpression("=", identifier(thisBinding), identifier("this"))]);
311
363
  }
312
364
 
313
365
  });
@@ -317,7 +369,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
317
369
  function getSuperBinding(thisEnvFn) {
318
370
  return getBinding(thisEnvFn, "supercall", () => {
319
371
  const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
320
- return t.arrowFunctionExpression([t.restElement(argsBinding)], t.callExpression(t.super(), [t.spreadElement(t.identifier(argsBinding.name))]));
372
+ return arrowFunctionExpression([restElement(argsBinding)], callExpression(_super(), [spreadElement(identifier(argsBinding.name))]));
321
373
  });
322
374
  }
323
375
 
@@ -328,20 +380,20 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
328
380
  let fnBody;
329
381
 
330
382
  if (propName) {
331
- fnBody = t.memberExpression(t.super(), t.identifier(propName));
383
+ fnBody = memberExpression(_super(), identifier(propName));
332
384
  } else {
333
385
  const method = thisEnvFn.scope.generateUidIdentifier("prop");
334
386
  argsList.unshift(method);
335
- fnBody = t.memberExpression(t.super(), t.identifier(method.name), true);
387
+ fnBody = memberExpression(_super(), identifier(method.name), true);
336
388
  }
337
389
 
338
390
  if (isAssignment) {
339
391
  const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
340
392
  argsList.push(valueIdent);
341
- fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name));
393
+ fnBody = assignmentExpression("=", fnBody, identifier(valueIdent.name));
342
394
  }
343
395
 
344
- return t.arrowFunctionExpression(argsList, fnBody);
396
+ return arrowFunctionExpression(argsList, fnBody);
345
397
  });
346
398
  }
347
399
 
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.evaluateTruthy = evaluateTruthy;
7
6
  exports.evaluate = evaluate;
7
+ exports.evaluateTruthy = evaluateTruthy;
8
8
  const VALID_CALLEES = ["String", "Number", "Math"];
9
9
  const INVALID_METHODS = ["random"];
10
10