@babel/traverse 7.6.2 → 7.6.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,15 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _path = _interopRequireDefault(require("./path"));
9
9
 
10
- function t() {
11
- const data = _interopRequireWildcard(require("@babel/types"));
12
-
13
- t = function () {
14
- return data;
15
- };
16
-
17
- return data;
18
- }
10
+ var t = _interopRequireWildcard(require("@babel/types"));
19
11
 
20
12
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
21
13
 
@@ -38,7 +30,7 @@ class TraversalContext {
38
30
  const opts = this.opts;
39
31
  if (opts.enter || opts.exit) return true;
40
32
  if (opts[node.type]) return true;
41
- const keys = t().VISITOR_KEYS[node.type];
33
+ const keys = t.VISITOR_KEYS[node.type];
42
34
  if (!keys || !keys.length) return false;
43
35
 
44
36
  for (const key of keys) {
package/lib/index.js CHANGED
@@ -30,25 +30,9 @@ var visitors = _interopRequireWildcard(require("./visitors"));
30
30
 
31
31
  exports.visitors = visitors;
32
32
 
33
- function _includes() {
34
- const data = _interopRequireDefault(require("lodash/includes"));
33
+ var _includes = _interopRequireDefault(require("lodash/includes"));
35
34
 
36
- _includes = function () {
37
- return data;
38
- };
39
-
40
- return data;
41
- }
42
-
43
- function t() {
44
- const data = _interopRequireWildcard(require("@babel/types"));
45
-
46
- t = function () {
47
- return data;
48
- };
49
-
50
- return data;
51
- }
35
+ var t = _interopRequireWildcard(require("@babel/types"));
52
36
 
53
37
  var cache = _interopRequireWildcard(require("./cache"));
54
38
 
@@ -83,11 +67,11 @@ traverse.verify = visitors.verify;
83
67
  traverse.explode = visitors.explode;
84
68
 
85
69
  traverse.cheap = function (node, enter) {
86
- return t().traverseFast(node, enter);
70
+ return t.traverseFast(node, enter);
87
71
  };
88
72
 
89
73
  traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
90
- const keys = t().VISITOR_KEYS[node.type];
74
+ const keys = t.VISITOR_KEYS[node.type];
91
75
  if (!keys) return;
92
76
  const context = new _context.default(scope, opts, state, parentPath);
93
77
 
@@ -98,12 +82,12 @@ traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
98
82
  };
99
83
 
100
84
  traverse.clearNode = function (node, opts) {
101
- t().removeProperties(node, opts);
85
+ t.removeProperties(node, opts);
102
86
  cache.path.delete(node);
103
87
  };
104
88
 
105
89
  traverse.removeProperties = function (tree, opts) {
106
- t().traverseFast(tree, traverse.clearNode, opts);
90
+ t.traverseFast(tree, traverse.clearNode, opts);
107
91
  return tree;
108
92
  };
109
93
 
@@ -115,7 +99,7 @@ function hasBlacklistedType(path, state) {
115
99
  }
116
100
 
117
101
  traverse.hasType = function (tree, type, blacklistTypes) {
118
- if ((0, _includes().default)(blacklistTypes, tree.type)) return false;
102
+ if ((0, _includes.default)(blacklistTypes, tree.type)) return false;
119
103
  if (tree.type === type) return true;
120
104
  const state = {
121
105
  has: false,
@@ -14,15 +14,7 @@ exports.isAncestor = isAncestor;
14
14
  exports.isDescendant = isDescendant;
15
15
  exports.inType = inType;
16
16
 
17
- function t() {
18
- const data = _interopRequireWildcard(require("@babel/types"));
19
-
20
- t = function () {
21
- return data;
22
- };
23
-
24
- return data;
25
- }
17
+ var t = _interopRequireWildcard(require("@babel/types"));
26
18
 
27
19
  var _index = _interopRequireDefault(require("./index"));
28
20
 
@@ -77,7 +69,7 @@ function getStatementParent() {
77
69
  function getEarliestCommonAncestorFrom(paths) {
78
70
  return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
79
71
  let earliest;
80
- const keys = t().VISITOR_KEYS[deepest.type];
72
+ const keys = t.VISITOR_KEYS[deepest.type];
81
73
 
82
74
  for (const ancestry of ancestries) {
83
75
  const path = ancestry[i + 1];
@@ -7,15 +7,7 @@ exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
7
7
  exports.addComment = addComment;
8
8
  exports.addComments = addComments;
9
9
 
10
- function t() {
11
- const data = _interopRequireWildcard(require("@babel/types"));
12
-
13
- t = function () {
14
- return data;
15
- };
16
-
17
- return data;
18
- }
10
+ var t = _interopRequireWildcard(require("@babel/types"));
19
11
 
20
12
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
21
13
 
@@ -41,9 +33,9 @@ function shareCommentsWithSiblings() {
41
33
  }
42
34
 
43
35
  function addComment(type, content, line) {
44
- t().addComment(this.node, type, content, line);
36
+ t.addComment(this.node, type, content, line);
45
37
  }
46
38
 
47
39
  function addComments(type, comments) {
48
- t().addComments(this.node, type, comments);
40
+ t.addComments(this.node, type, comments);
49
41
  }
@@ -9,25 +9,9 @@ exports.arrowFunctionToShadowed = arrowFunctionToShadowed;
9
9
  exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
10
10
  exports.arrowFunctionToExpression = arrowFunctionToExpression;
11
11
 
12
- function t() {
13
- const data = _interopRequireWildcard(require("@babel/types"));
12
+ var t = _interopRequireWildcard(require("@babel/types"));
14
13
 
15
- t = function () {
16
- return data;
17
- };
18
-
19
- return data;
20
- }
21
-
22
- function _helperFunctionName() {
23
- const data = _interopRequireDefault(require("@babel/helper-function-name"));
24
-
25
- _helperFunctionName = function () {
26
- return data;
27
- };
28
-
29
- return data;
30
- }
14
+ var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name"));
31
15
 
32
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
17
 
@@ -48,7 +32,7 @@ function toComputedKey() {
48
32
  }
49
33
 
50
34
  if (!node.computed) {
51
- if (t().isIdentifier(key)) key = t().stringLiteral(key.name);
35
+ if (t.isIdentifier(key)) key = t.stringLiteral(key.name);
52
36
  }
53
37
 
54
38
  return key;
@@ -84,14 +68,14 @@ function ensureBlock() {
84
68
 
85
69
  if (this.isFunction()) {
86
70
  key = "argument";
87
- statements.push(t().returnStatement(body.node));
71
+ statements.push(t.returnStatement(body.node));
88
72
  } else {
89
73
  key = "expression";
90
- statements.push(t().expressionStatement(body.node));
74
+ statements.push(t.expressionStatement(body.node));
91
75
  }
92
76
  }
93
77
 
94
- this.node.body = t().blockStatement(statements);
78
+ this.node.body = t.blockStatement(statements);
95
79
  const parentPath = this.get(stringPath);
96
80
  body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
97
81
  return this.node;
@@ -128,12 +112,12 @@ function arrowFunctionToExpression({
128
112
  if (checkBinding) {
129
113
  this.parentPath.scope.push({
130
114
  id: checkBinding,
131
- init: t().objectExpression([])
115
+ init: t.objectExpression([])
132
116
  });
133
117
  }
134
118
 
135
- this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)])));
136
- this.replaceWith(t().callExpression(t().memberExpression((0, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()]));
119
+ this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)])));
120
+ this.replaceWith(t.callExpression(t.memberExpression((0, _helperFunctionName.default)(this, true) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
137
121
  }
138
122
  }
139
123
 
@@ -181,7 +165,7 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
181
165
  });
182
166
  const superBinding = getSuperBinding(thisEnvFn);
183
167
  allSuperCalls.forEach(superCall => {
184
- const callee = t().identifier(superBinding);
168
+ const callee = t.identifier(superBinding);
185
169
  callee.loc = superCall.node.callee.loc;
186
170
  superCall.get("callee").replaceWith(callee);
187
171
  });
@@ -194,7 +178,7 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
194
178
 
195
179
  if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
196
180
  thisPaths.forEach(thisChild => {
197
- const thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding);
181
+ const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
198
182
  thisRef.loc = thisChild.node.loc;
199
183
  thisChild.replaceWith(thisRef);
200
184
  });
@@ -203,18 +187,18 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
203
187
  }
204
188
 
205
189
  if (argumentsPaths.length > 0) {
206
- const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t().identifier("arguments"));
190
+ const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t.identifier("arguments"));
207
191
  argumentsPaths.forEach(argumentsChild => {
208
- const argsRef = t().identifier(argumentsBinding);
192
+ const argsRef = t.identifier(argumentsBinding);
209
193
  argsRef.loc = argumentsChild.node.loc;
210
194
  argumentsChild.replaceWith(argsRef);
211
195
  });
212
196
  }
213
197
 
214
198
  if (newTargetPaths.length > 0) {
215
- const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t().metaProperty(t().identifier("new"), t().identifier("target")));
199
+ const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t.metaProperty(t.identifier("new"), t.identifier("target")));
216
200
  newTargetPaths.forEach(targetChild => {
217
- const targetRef = t().identifier(newTargetBinding);
201
+ const targetRef = t.identifier(newTargetBinding);
218
202
  targetRef.loc = targetChild.node.loc;
219
203
  targetChild.replaceWith(targetRef);
220
204
  });
@@ -236,10 +220,10 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
236
220
 
237
221
  if (superProp.node.computed) {
238
222
  const prop = superProp.get("property").node;
239
- superProp.replaceWith(t().identifier(superBinding));
223
+ superProp.replaceWith(t.identifier(superBinding));
240
224
  superProp.parentPath.node.arguments.unshift(prop);
241
225
  } else {
242
- superProp.replaceWith(t().identifier(superBinding));
226
+ superProp.replaceWith(t.identifier(superBinding));
243
227
  }
244
228
  } else {
245
229
  const isAssignment = superProp.parentPath.isAssignmentExpression({
@@ -255,9 +239,9 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
255
239
  if (isAssignment) {
256
240
  const value = superProp.parentPath.node.right;
257
241
  args.push(value);
258
- superProp.parentPath.replaceWith(t().callExpression(t().identifier(superBinding), args));
242
+ superProp.parentPath.replaceWith(t.callExpression(t.identifier(superBinding), args));
259
243
  } else {
260
- superProp.replaceWith(t().callExpression(t().identifier(superBinding), args));
244
+ superProp.replaceWith(t.callExpression(t.identifier(superBinding), args));
261
245
  }
262
246
  }
263
247
  });
@@ -275,11 +259,11 @@ function standardizeSuperProperty(superProp) {
275
259
 
276
260
  if (superProp.node.computed) {
277
261
  const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
278
- assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true));
279
- assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value));
262
+ assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, t.assignmentExpression("=", tmp, superProp.node.property), true));
263
+ assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(tmp.name), true), value));
280
264
  } else {
281
- assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, superProp.node.property));
282
- assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(superProp.node.property.name)), value));
265
+ assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, superProp.node.property));
266
+ assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(superProp.node.property.name)), value));
283
267
  }
284
268
 
285
269
  return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
@@ -287,13 +271,13 @@ function standardizeSuperProperty(superProp) {
287
271
  const updateExpr = superProp.parentPath;
288
272
  const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
289
273
  const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
290
- 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)))];
274
+ 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)))];
291
275
 
292
276
  if (!superProp.parentPath.node.prefix) {
293
- parts.push(t().identifier(tmp.name));
277
+ parts.push(t.identifier(tmp.name));
294
278
  }
295
279
 
296
- updateExpr.replaceWith(t().sequenceExpression(parts));
280
+ updateExpr.replaceWith(t.sequenceExpression(parts));
297
281
  const left = updateExpr.get("expressions.0.right");
298
282
  const right = updateExpr.get("expressions.1.left");
299
283
  return [left, right];
@@ -308,7 +292,7 @@ function hasSuperClass(thisEnvFn) {
308
292
 
309
293
  function getThisBinding(thisEnvFn, inConstructor) {
310
294
  return getBinding(thisEnvFn, "this", thisBinding => {
311
- if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression();
295
+ if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
312
296
  const supers = new WeakSet();
313
297
  thisEnvFn.traverse({
314
298
  Function(child) {
@@ -324,7 +308,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
324
308
  if (!child.get("callee").isSuper()) return;
325
309
  if (supers.has(child.node)) return;
326
310
  supers.add(child.node);
327
- child.replaceWithMultiple([child.node, t().assignmentExpression("=", t().identifier(thisBinding), t().identifier("this"))]);
311
+ child.replaceWithMultiple([child.node, t.assignmentExpression("=", t.identifier(thisBinding), t.identifier("this"))]);
328
312
  }
329
313
 
330
314
  });
@@ -334,25 +318,25 @@ function getThisBinding(thisEnvFn, inConstructor) {
334
318
  function getSuperBinding(thisEnvFn) {
335
319
  return getBinding(thisEnvFn, "supercall", () => {
336
320
  const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
337
- return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))]));
321
+ return t.arrowFunctionExpression([t.restElement(argsBinding)], t.callExpression(t.super(), [t.spreadElement(t.identifier(argsBinding.name))]));
338
322
  });
339
323
  }
340
324
 
341
325
  function getSuperPropCallBinding(thisEnvFn, propName) {
342
326
  return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => {
343
327
  const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
344
- const argsList = [t().restElement(argsBinding)];
328
+ const argsList = [t.restElement(argsBinding)];
345
329
  let fnBody;
346
330
 
347
331
  if (propName) {
348
- fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]);
332
+ fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(propName)), [t.spreadElement(t.identifier(argsBinding.name))]);
349
333
  } else {
350
334
  const method = thisEnvFn.scope.generateUidIdentifier("prop");
351
335
  argsList.unshift(method);
352
- fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]);
336
+ fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(method.name), true), [t.spreadElement(t.identifier(argsBinding.name))]);
353
337
  }
354
338
 
355
- return t().arrowFunctionExpression(argsList, fnBody);
339
+ return t.arrowFunctionExpression(argsList, fnBody);
356
340
  });
357
341
  }
358
342
 
@@ -363,20 +347,20 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
363
347
  let fnBody;
364
348
 
365
349
  if (propName) {
366
- fnBody = t().memberExpression(t().super(), t().identifier(propName));
350
+ fnBody = t.memberExpression(t.super(), t.identifier(propName));
367
351
  } else {
368
352
  const method = thisEnvFn.scope.generateUidIdentifier("prop");
369
353
  argsList.unshift(method);
370
- fnBody = t().memberExpression(t().super(), t().identifier(method.name), true);
354
+ fnBody = t.memberExpression(t.super(), t.identifier(method.name), true);
371
355
  }
372
356
 
373
357
  if (isAssignment) {
374
358
  const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
375
359
  argsList.push(valueIdent);
376
- fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name));
360
+ fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name));
377
361
  }
378
362
 
379
- return t().arrowFunctionExpression(argsList, fnBody);
363
+ return t.arrowFunctionExpression(argsList, fnBody);
380
364
  });
381
365
  }
382
366
 
@@ -20,15 +20,7 @@ exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
20
20
 
21
21
  var _index = _interopRequireDefault(require("./index"));
22
22
 
23
- function t() {
24
- const data = _interopRequireWildcard(require("@babel/types"));
25
-
26
- t = function () {
27
- return data;
28
- };
29
-
30
- return data;
31
- }
23
+ var t = _interopRequireWildcard(require("@babel/types"));
32
24
 
33
25
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
34
26
 
@@ -224,11 +216,11 @@ function _getPattern(parts, context) {
224
216
  }
225
217
 
226
218
  function getBindingIdentifiers(duplicates) {
227
- return t().getBindingIdentifiers(this.node, duplicates);
219
+ return t.getBindingIdentifiers(this.node, duplicates);
228
220
  }
229
221
 
230
222
  function getOuterBindingIdentifiers(duplicates) {
231
- return t().getOuterBindingIdentifiers(this.node, duplicates);
223
+ return t.getOuterBindingIdentifiers(this.node, duplicates);
232
224
  }
233
225
 
234
226
  function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
@@ -240,7 +232,7 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
240
232
  const id = search.shift();
241
233
  if (!id) continue;
242
234
  if (!id.node) continue;
243
- const keys = t().getBindingIdentifiers.keys[id.node.type];
235
+ const keys = t.getBindingIdentifiers.keys[id.node.type];
244
236
 
245
237
  if (id.isIdentifier()) {
246
238
  if (duplicates) {
package/lib/path/index.js CHANGED
@@ -7,41 +7,17 @@ exports.default = void 0;
7
7
 
8
8
  var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types"));
9
9
 
10
- function _debug() {
11
- const data = _interopRequireDefault(require("debug"));
12
-
13
- _debug = function () {
14
- return data;
15
- };
16
-
17
- return data;
18
- }
10
+ var _debug = _interopRequireDefault(require("debug"));
19
11
 
20
12
  var _index = _interopRequireDefault(require("../index"));
21
13
 
22
14
  var _scope = _interopRequireDefault(require("../scope"));
23
15
 
24
- function t() {
25
- const data = _interopRequireWildcard(require("@babel/types"));
26
-
27
- t = function () {
28
- return data;
29
- };
30
-
31
- return data;
32
- }
16
+ var t = _interopRequireWildcard(require("@babel/types"));
33
17
 
34
18
  var _cache = require("../cache");
35
19
 
36
- function _generator() {
37
- const data = _interopRequireDefault(require("@babel/generator"));
38
-
39
- _generator = function () {
40
- return data;
41
- };
42
-
43
- return data;
44
- }
20
+ var _generator = _interopRequireDefault(require("@babel/generator"));
45
21
 
46
22
  var NodePath_ancestry = _interopRequireWildcard(require("./ancestry"));
47
23
 
@@ -71,7 +47,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
71
47
 
72
48
  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; }
73
49
 
74
- const debug = (0, _debug().default)("babel");
50
+ const debug = (0, _debug.default)("babel");
75
51
 
76
52
  class NodePath {
77
53
  constructor(hub, parent) {
@@ -164,7 +140,7 @@ class NodePath {
164
140
  }
165
141
 
166
142
  set(key, node) {
167
- t().validate(this.node, key, node);
143
+ t.validate(this.node, key, node);
168
144
  this.node[key] = node;
169
145
  }
170
146
 
@@ -187,7 +163,7 @@ class NodePath {
187
163
  }
188
164
 
189
165
  toString() {
190
- return (0, _generator().default)(this.node).code;
166
+ return (0, _generator.default)(this.node).code;
191
167
  }
192
168
 
193
169
  }
@@ -195,9 +171,9 @@ class NodePath {
195
171
  exports.default = NodePath;
196
172
  Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments);
197
173
 
198
- for (const type of t().TYPES) {
174
+ for (const type of t.TYPES) {
199
175
  const typeKey = `is${type}`;
200
- const fn = t()[typeKey];
176
+ const fn = t[typeKey];
201
177
 
202
178
  NodePath.prototype[typeKey] = function (opts) {
203
179
  return fn(this.node, opts);
@@ -212,7 +188,7 @@ for (const type of t().TYPES) {
212
188
 
213
189
  for (const type of Object.keys(virtualTypes)) {
214
190
  if (type[0] === "_") continue;
215
- if (t().TYPES.indexOf(type) < 0) t().TYPES.push(type);
191
+ if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type);
216
192
  const virtualType = virtualTypes[type];
217
193
 
218
194
  NodePath.prototype[`is${type}`] = function (opts) {
@@ -12,15 +12,7 @@ exports.isGenericType = isGenericType;
12
12
 
13
13
  var inferers = _interopRequireWildcard(require("./inferers"));
14
14
 
15
- function t() {
16
- const data = _interopRequireWildcard(require("@babel/types"));
17
-
18
- t = function () {
19
- return data;
20
- };
21
-
22
- return data;
23
- }
15
+ var t = _interopRequireWildcard(require("@babel/types"));
24
16
 
25
17
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
26
18
 
@@ -28,8 +20,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
28
20
 
29
21
  function getTypeAnnotation() {
30
22
  if (this.typeAnnotation) return this.typeAnnotation;
31
- let type = this._getTypeAnnotation() || t().anyTypeAnnotation();
32
- if (t().isTypeAnnotation(type)) type = type.typeAnnotation;
23
+ let type = this._getTypeAnnotation() || t.anyTypeAnnotation();
24
+ if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
33
25
  return this.typeAnnotation = type;
34
26
  }
35
27
 
@@ -42,14 +34,14 @@ function _getTypeAnnotation() {
42
34
  const declarParent = declar.parentPath;
43
35
 
44
36
  if (declar.key === "left" && declarParent.isForInStatement()) {
45
- return t().stringTypeAnnotation();
37
+ return t.stringTypeAnnotation();
46
38
  }
47
39
 
48
40
  if (declar.key === "left" && declarParent.isForOfStatement()) {
49
- return t().anyTypeAnnotation();
41
+ return t.anyTypeAnnotation();
50
42
  }
51
43
 
52
- return t().voidTypeAnnotation();
44
+ return t.voidTypeAnnotation();
53
45
  } else {
54
46
  return;
55
47
  }
@@ -78,19 +70,19 @@ function isBaseType(baseName, soft) {
78
70
 
79
71
  function _isBaseType(baseName, type, soft) {
80
72
  if (baseName === "string") {
81
- return t().isStringTypeAnnotation(type);
73
+ return t.isStringTypeAnnotation(type);
82
74
  } else if (baseName === "number") {
83
- return t().isNumberTypeAnnotation(type);
75
+ return t.isNumberTypeAnnotation(type);
84
76
  } else if (baseName === "boolean") {
85
- return t().isBooleanTypeAnnotation(type);
77
+ return t.isBooleanTypeAnnotation(type);
86
78
  } else if (baseName === "any") {
87
- return t().isAnyTypeAnnotation(type);
79
+ return t.isAnyTypeAnnotation(type);
88
80
  } else if (baseName === "mixed") {
89
- return t().isMixedTypeAnnotation(type);
81
+ return t.isMixedTypeAnnotation(type);
90
82
  } else if (baseName === "empty") {
91
- return t().isEmptyTypeAnnotation(type);
83
+ return t.isEmptyTypeAnnotation(type);
92
84
  } else if (baseName === "void") {
93
- return t().isVoidTypeAnnotation(type);
85
+ return t.isVoidTypeAnnotation(type);
94
86
  } else {
95
87
  if (soft) {
96
88
  return false;
@@ -102,11 +94,11 @@ function _isBaseType(baseName, type, soft) {
102
94
 
103
95
  function couldBeBaseType(name) {
104
96
  const type = this.getTypeAnnotation();
105
- if (t().isAnyTypeAnnotation(type)) return true;
97
+ if (t.isAnyTypeAnnotation(type)) return true;
106
98
 
107
- if (t().isUnionTypeAnnotation(type)) {
99
+ if (t.isUnionTypeAnnotation(type)) {
108
100
  for (const type2 of type.types) {
109
- if (t().isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
101
+ if (t.isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
110
102
  return true;
111
103
  }
112
104
  }
@@ -121,14 +113,14 @@ function baseTypeStrictlyMatches(right) {
121
113
  const left = this.getTypeAnnotation();
122
114
  right = right.getTypeAnnotation();
123
115
 
124
- if (!t().isAnyTypeAnnotation(left) && t().isFlowBaseAnnotation(left)) {
116
+ if (!t.isAnyTypeAnnotation(left) && t.isFlowBaseAnnotation(left)) {
125
117
  return right.type === left.type;
126
118
  }
127
119
  }
128
120
 
129
121
  function isGenericType(genericName) {
130
122
  const type = this.getTypeAnnotation();
131
- return t().isGenericTypeAnnotation(type) && t().isIdentifier(type.id, {
123
+ return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, {
132
124
  name: genericName
133
125
  });
134
126
  }