@babel/traverse 7.6.0 → 7.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

@@ -5,21 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- function t() {
9
- const data = _interopRequireWildcard(require("@babel/types"));
8
+ var t = _interopRequireWildcard(require("@babel/types"));
10
9
 
11
- t = function () {
12
- return data;
13
- };
10
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
11
 
15
- return data;
16
- }
17
-
18
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
13
 
20
14
  const referenceVisitor = {
21
15
  ReferencedIdentifier(path, state) {
22
- if (path.isJSXIdentifier() && t().react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
16
+ if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
23
17
  return;
24
18
  }
25
19
 
@@ -37,6 +31,15 @@ const referenceVisitor = {
37
31
 
38
32
  const binding = path.scope.getBinding(path.node.name);
39
33
  if (!binding) return;
34
+
35
+ for (const violation of binding.constantViolations) {
36
+ if (violation.scope !== binding.path.scope) {
37
+ state.mutableBinding = true;
38
+ path.stop();
39
+ return;
40
+ }
41
+ }
42
+
40
43
  if (binding !== state.scope.getBinding(path.node.name)) return;
41
44
  state.bindings[path.node.name] = binding;
42
45
  }
@@ -47,6 +50,7 @@ class PathHoister {
47
50
  constructor(path, scope) {
48
51
  this.breakOnScopePaths = [];
49
52
  this.bindings = {};
53
+ this.mutableBinding = false;
50
54
  this.scopes = [];
51
55
  this.scope = scope;
52
56
  this.path = path;
@@ -165,21 +169,22 @@ class PathHoister {
165
169
 
166
170
  run() {
167
171
  this.path.traverse(referenceVisitor, this);
172
+ if (this.mutableBinding) return;
168
173
  this.getCompatibleScopes();
169
174
  const attachTo = this.getAttachmentPath();
170
175
  if (!attachTo) return;
171
176
  if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
172
177
  let uid = attachTo.scope.generateUidIdentifier("ref");
173
- const declarator = t().variableDeclarator(uid, this.path.node);
178
+ const declarator = t.variableDeclarator(uid, this.path.node);
174
179
  const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
175
- const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t().variableDeclaration("var", [declarator])]);
180
+ const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]);
176
181
  const parent = this.path.parentPath;
177
182
 
178
183
  if (parent.isJSXElement() && this.path.container === parent.node.children) {
179
- uid = t().JSXExpressionContainer(uid);
184
+ uid = t.JSXExpressionContainer(uid);
180
185
  }
181
186
 
182
- this.path.replaceWith(t().cloneNode(uid));
187
+ this.path.replaceWith(t.cloneNode(uid));
183
188
  return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
184
189
  }
185
190
 
@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0;
7
7
 
8
- function t() {
9
- const data = _interopRequireWildcard(require("@babel/types"));
8
+ var t = _interopRequireWildcard(require("@babel/types"));
10
9
 
11
- t = function () {
12
- return data;
13
- };
10
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
11
 
15
- return data;
16
- }
17
-
18
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
13
 
20
14
  const ReferencedIdentifier = {
21
15
  types: ["Identifier", "JSXIdentifier"],
@@ -26,15 +20,15 @@ const ReferencedIdentifier = {
26
20
  parent
27
21
  } = path;
28
22
 
29
- if (!t().isIdentifier(node, opts) && !t().isJSXMemberExpression(parent, opts)) {
30
- if (t().isJSXIdentifier(node, opts)) {
31
- if (t().react.isCompatTag(node.name)) return false;
23
+ if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
24
+ if (t.isJSXIdentifier(node, opts)) {
25
+ if (t.react.isCompatTag(node.name)) return false;
32
26
  } else {
33
27
  return false;
34
28
  }
35
29
  }
36
30
 
37
- return t().isReferenced(node, parent, path.parentPath.parent);
31
+ return t.isReferenced(node, parent, path.parentPath.parent);
38
32
  }
39
33
 
40
34
  };
@@ -46,7 +40,7 @@ const ReferencedMemberExpression = {
46
40
  node,
47
41
  parent
48
42
  }) {
49
- return t().isMemberExpression(node) && t().isReferenced(node, parent);
43
+ return t.isMemberExpression(node) && t.isReferenced(node, parent);
50
44
  }
51
45
 
52
46
  };
@@ -60,7 +54,7 @@ const BindingIdentifier = {
60
54
  parent
61
55
  } = path;
62
56
  const grandparent = path.parentPath.parent;
63
- return t().isIdentifier(node) && t().isBinding(node, parent, grandparent);
57
+ return t.isIdentifier(node) && t.isBinding(node, parent, grandparent);
64
58
  }
65
59
 
66
60
  };
@@ -72,12 +66,12 @@ const Statement = {
72
66
  node,
73
67
  parent
74
68
  }) {
75
- if (t().isStatement(node)) {
76
- if (t().isVariableDeclaration(node)) {
77
- if (t().isForXStatement(parent, {
69
+ if (t.isStatement(node)) {
70
+ if (t.isVariableDeclaration(node)) {
71
+ if (t.isForXStatement(parent, {
78
72
  left: node
79
73
  })) return false;
80
- if (t().isForStatement(parent, {
74
+ if (t.isForStatement(parent, {
81
75
  init: node
82
76
  })) return false;
83
77
  }
@@ -97,7 +91,7 @@ const Expression = {
97
91
  if (path.isIdentifier()) {
98
92
  return path.isReferencedIdentifier();
99
93
  } else {
100
- return t().isExpression(path.node);
94
+ return t.isExpression(path.node);
101
95
  }
102
96
  }
103
97
 
@@ -107,21 +101,21 @@ const Scope = {
107
101
  types: ["Scopable"],
108
102
 
109
103
  checkPath(path) {
110
- return t().isScope(path.node, path.parent);
104
+ return t.isScope(path.node, path.parent);
111
105
  }
112
106
 
113
107
  };
114
108
  exports.Scope = Scope;
115
109
  const Referenced = {
116
110
  checkPath(path) {
117
- return t().isReferenced(path.node, path.parent);
111
+ return t.isReferenced(path.node, path.parent);
118
112
  }
119
113
 
120
114
  };
121
115
  exports.Referenced = Referenced;
122
116
  const BlockScoped = {
123
117
  checkPath(path) {
124
- return t().isBlockScoped(path.node);
118
+ return t.isBlockScoped(path.node);
125
119
  }
126
120
 
127
121
  };
@@ -130,7 +124,7 @@ const Var = {
130
124
  types: ["VariableDeclaration"],
131
125
 
132
126
  checkPath(path) {
133
- return t().isVar(path.node);
127
+ return t.isVar(path.node);
134
128
  }
135
129
 
136
130
  };
@@ -162,13 +156,13 @@ const Flow = {
162
156
  checkPath({
163
157
  node
164
158
  }) {
165
- if (t().isFlow(node)) {
159
+ if (t.isFlow(node)) {
166
160
  return true;
167
- } else if (t().isImportDeclaration(node)) {
161
+ } else if (t.isImportDeclaration(node)) {
168
162
  return node.importKind === "type" || node.importKind === "typeof";
169
- } else if (t().isExportDeclaration(node)) {
163
+ } else if (t.isExportDeclaration(node)) {
170
164
  return node.exportKind === "type";
171
- } else if (t().isImportSpecifier(node)) {
165
+ } else if (t.isImportSpecifier(node)) {
172
166
  return node.importKind === "type" || node.importKind === "typeof";
173
167
  } else {
174
168
  return false;
@@ -20,17 +20,11 @@ var _hoister = _interopRequireDefault(require("./lib/hoister"));
20
20
 
21
21
  var _index = _interopRequireDefault(require("./index"));
22
22
 
23
- function t() {
24
- const data = _interopRequireWildcard(require("@babel/types"));
23
+ var t = _interopRequireWildcard(require("@babel/types"));
25
24
 
26
- t = function () {
27
- return data;
28
- };
25
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
29
26
 
30
- return data;
31
- }
32
-
33
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
27
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
34
28
 
35
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
30
 
@@ -51,7 +45,7 @@ function insertBefore(nodes) {
51
45
  return this._containerInsertBefore(nodes);
52
46
  } else if (this.isStatementOrBlock()) {
53
47
  const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
54
- this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : []));
48
+ this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
55
49
  return this.unshiftContainer("body", nodes);
56
50
  } else {
57
51
  throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
@@ -105,7 +99,7 @@ function insertAfter(nodes) {
105
99
 
106
100
  if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
107
101
  return parentPath.insertAfter(nodes.map(node => {
108
- return t().isExpression(node) ? t().expressionStatement(node) : node;
102
+ return t.isExpression(node) ? t.expressionStatement(node) : node;
109
103
  }));
110
104
  } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
111
105
  if (this.node) {
@@ -121,8 +115,8 @@ function insertAfter(nodes) {
121
115
  }
122
116
 
123
117
  const temp = scope.generateDeclaredUidIdentifier();
124
- nodes.unshift(t().expressionStatement(t().assignmentExpression("=", t().cloneNode(temp), this.node)));
125
- nodes.push(t().expressionStatement(t().cloneNode(temp)));
118
+ nodes.unshift(t.expressionStatement(t.assignmentExpression("=", t.cloneNode(temp), this.node)));
119
+ nodes.push(t.expressionStatement(t.cloneNode(temp)));
126
120
  }
127
121
 
128
122
  return this.replaceExpressionWithStatements(nodes);
@@ -130,7 +124,7 @@ function insertAfter(nodes) {
130
124
  return this._containerInsertAfter(nodes);
131
125
  } else if (this.isStatementOrBlock()) {
132
126
  const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
133
- this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : []));
127
+ this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
134
128
  return this.pushContainer("body", nodes);
135
129
  } else {
136
130
  throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
@@ -12,6 +12,8 @@ exports._assertUnremoved = _assertUnremoved;
12
12
 
13
13
  var _removalHooks = require("./lib/removal-hooks");
14
14
 
15
+ var _index = require("./index");
16
+
15
17
  function remove() {
16
18
  this._assertUnremoved();
17
19
 
@@ -53,8 +55,7 @@ function _remove() {
53
55
  }
54
56
 
55
57
  function _markRemoved() {
56
- this.shouldSkip = true;
57
- this.removed = true;
58
+ this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
58
59
  this.node = null;
59
60
  }
60
61
 
@@ -10,41 +10,19 @@ exports._replaceWith = _replaceWith;
10
10
  exports.replaceExpressionWithStatements = replaceExpressionWithStatements;
11
11
  exports.replaceInline = replaceInline;
12
12
 
13
- function _codeFrame() {
14
- const data = require("@babel/code-frame");
15
-
16
- _codeFrame = function () {
17
- return data;
18
- };
19
-
20
- return data;
21
- }
13
+ var _codeFrame = require("@babel/code-frame");
22
14
 
23
15
  var _index = _interopRequireDefault(require("../index"));
24
16
 
25
17
  var _index2 = _interopRequireDefault(require("./index"));
26
18
 
27
- function _parser() {
28
- const data = require("@babel/parser");
29
-
30
- _parser = function () {
31
- return data;
32
- };
19
+ var _parser = require("@babel/parser");
33
20
 
34
- return data;
35
- }
36
-
37
- function t() {
38
- const data = _interopRequireWildcard(require("@babel/types"));
21
+ var t = _interopRequireWildcard(require("@babel/types"));
39
22
 
40
- t = function () {
41
- return data;
42
- };
43
-
44
- return data;
45
- }
23
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
46
24
 
47
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
25
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
48
26
 
49
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
28
 
@@ -67,7 +45,7 @@ const hoistVariablesVisitor = {
67
45
 
68
46
  for (const declar of path.node.declarations) {
69
47
  if (declar.init) {
70
- exprs.push(t().expressionStatement(t().assignmentExpression("=", declar.id, declar.init)));
48
+ exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
71
49
  }
72
50
  }
73
51
 
@@ -79,8 +57,8 @@ const hoistVariablesVisitor = {
79
57
  function replaceWithMultiple(nodes) {
80
58
  this.resync();
81
59
  nodes = this._verifyNodeList(nodes);
82
- t().inheritLeadingComments(nodes[0], this.node);
83
- t().inheritTrailingComments(nodes[nodes.length - 1], this.node);
60
+ t.inheritLeadingComments(nodes[0], this.node);
61
+ t.inheritTrailingComments(nodes[nodes.length - 1], this.node);
84
62
  this.node = this.container[this.key] = null;
85
63
  const paths = this.insertAfter(nodes);
86
64
 
@@ -98,12 +76,12 @@ function replaceWithSourceString(replacement) {
98
76
 
99
77
  try {
100
78
  replacement = `(${replacement})`;
101
- replacement = (0, _parser().parse)(replacement);
79
+ replacement = (0, _parser.parse)(replacement);
102
80
  } catch (err) {
103
81
  const loc = err.loc;
104
82
 
105
83
  if (loc) {
106
- err.message += " - make sure this is an expression.\n" + (0, _codeFrame().codeFrameColumns)(replacement, {
84
+ err.message += " - make sure this is an expression.\n" + (0, _codeFrame.codeFrameColumns)(replacement, {
107
85
  start: {
108
86
  line: loc.line,
109
87
  column: loc.column + 1
@@ -141,7 +119,7 @@ function replaceWith(replacement) {
141
119
  return [this];
142
120
  }
143
121
 
144
- if (this.isProgram() && !t().isProgram(replacement)) {
122
+ if (this.isProgram() && !t.isProgram(replacement)) {
145
123
  throw new Error("You can only replace a Program root node with another Program node");
146
124
  }
147
125
 
@@ -155,14 +133,14 @@ function replaceWith(replacement) {
155
133
 
156
134
  let nodePath = "";
157
135
 
158
- if (this.isNodeType("Statement") && t().isExpression(replacement)) {
136
+ if (this.isNodeType("Statement") && t.isExpression(replacement)) {
159
137
  if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) {
160
- replacement = t().expressionStatement(replacement);
138
+ replacement = t.expressionStatement(replacement);
161
139
  nodePath = "expression";
162
140
  }
163
141
  }
164
142
 
165
- if (this.isNodeType("Expression") && t().isStatement(replacement)) {
143
+ if (this.isNodeType("Expression") && t.isStatement(replacement)) {
166
144
  if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
167
145
  return this.replaceExpressionWithStatements([replacement]);
168
146
  }
@@ -171,8 +149,8 @@ function replaceWith(replacement) {
171
149
  const oldNode = this.node;
172
150
 
173
151
  if (oldNode) {
174
- t().inheritsComments(replacement, oldNode);
175
- t().removeComments(oldNode);
152
+ t.inheritsComments(replacement, oldNode);
153
+ t.removeComments(oldNode);
176
154
  }
177
155
 
178
156
  this._replaceWith(replacement);
@@ -189,9 +167,9 @@ function _replaceWith(node) {
189
167
  }
190
168
 
191
169
  if (this.inList) {
192
- t().validate(this.parent, this.key, [node]);
170
+ t.validate(this.parent, this.key, [node]);
193
171
  } else {
194
- t().validate(this.parent, this.key, node);
172
+ t.validate(this.parent, this.key, node);
195
173
  }
196
174
 
197
175
  this.debug(`Replace with ${node && node.type}`);
@@ -200,7 +178,7 @@ function _replaceWith(node) {
200
178
 
201
179
  function replaceExpressionWithStatements(nodes) {
202
180
  this.resync();
203
- const toSequenceExpression = t().toSequenceExpression(nodes, this.scope);
181
+ const toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
204
182
 
205
183
  if (toSequenceExpression) {
206
184
  return this.replaceWith(toSequenceExpression)[0].get("expressions");
@@ -208,8 +186,8 @@ function replaceExpressionWithStatements(nodes) {
208
186
 
209
187
  const functionParent = this.getFunctionParent();
210
188
  const isParentAsync = functionParent && functionParent.is("async");
211
- const container = t().arrowFunctionExpression([], t().blockStatement(nodes));
212
- this.replaceWith(t().callExpression(container, []));
189
+ const container = t.arrowFunctionExpression([], t.blockStatement(nodes));
190
+ this.replaceWith(t.callExpression(container, []));
213
191
  this.traverse(hoistVariablesVisitor);
214
192
  const completionRecords = this.get("callee").getCompletionRecords();
215
193
 
@@ -223,24 +201,24 @@ function replaceExpressionWithStatements(nodes) {
223
201
  if (!uid) {
224
202
  const callee = this.get("callee");
225
203
  uid = callee.scope.generateDeclaredUidIdentifier("ret");
226
- callee.get("body").pushContainer("body", t().returnStatement(t().cloneNode(uid)));
204
+ callee.get("body").pushContainer("body", t.returnStatement(t.cloneNode(uid)));
227
205
  loop.setData("expressionReplacementReturnUid", uid);
228
206
  } else {
229
- uid = t().identifier(uid.name);
207
+ uid = t.identifier(uid.name);
230
208
  }
231
209
 
232
- path.get("expression").replaceWith(t().assignmentExpression("=", t().cloneNode(uid), path.node.expression));
210
+ path.get("expression").replaceWith(t.assignmentExpression("=", t.cloneNode(uid), path.node.expression));
233
211
  } else {
234
- path.replaceWith(t().returnStatement(path.node.expression));
212
+ path.replaceWith(t.returnStatement(path.node.expression));
235
213
  }
236
214
  }
237
215
 
238
216
  const callee = this.get("callee");
239
217
  callee.arrowFunctionToExpression();
240
218
 
241
- if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t().FUNCTION_TYPES)) {
219
+ if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t.FUNCTION_TYPES)) {
242
220
  callee.set("async", true);
243
- this.replaceWith(t().awaitExpression(this.node));
221
+ this.replaceWith(t.awaitExpression(this.node));
244
222
  }
245
223
 
246
224
  return callee.get("body.body");