@babel/traverse 7.6.2 → 7.7.4

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

Potentially problematic release.


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

package/lib/path/index.js CHANGED
@@ -3,45 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.SHOULD_SKIP = exports.SHOULD_STOP = exports.REMOVED = 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
 
@@ -69,19 +45,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
69
45
 
70
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
71
47
 
72
- 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
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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");
51
+ const REMOVED = 1 << 0;
52
+ exports.REMOVED = REMOVED;
53
+ const SHOULD_STOP = 1 << 1;
54
+ exports.SHOULD_STOP = SHOULD_STOP;
55
+ const SHOULD_SKIP = 1 << 2;
56
+ exports.SHOULD_SKIP = SHOULD_SKIP;
75
57
 
76
58
  class NodePath {
77
59
  constructor(hub, parent) {
78
60
  this.parent = parent;
79
61
  this.hub = hub;
80
62
  this.contexts = [];
81
- this.data = Object.create(null);
82
- this.shouldSkip = false;
83
- this.shouldStop = false;
84
- this.removed = false;
63
+ this.data = null;
64
+ this._traverseFlags = 0;
85
65
  this.state = null;
86
66
  this.opts = null;
87
67
  this.skipKeys = null;
@@ -89,13 +69,10 @@ class NodePath {
89
69
  this.context = null;
90
70
  this.container = null;
91
71
  this.listKey = null;
92
- this.inList = false;
93
- this.parentKey = null;
94
72
  this.key = null;
95
73
  this.node = null;
96
74
  this.scope = null;
97
75
  this.type = null;
98
- this.typeAnnotation = null;
99
76
  }
100
77
 
101
78
  static get({
@@ -146,10 +123,18 @@ class NodePath {
146
123
  }
147
124
 
148
125
  setData(key, val) {
126
+ if (this.data == null) {
127
+ this.data = Object.create(null);
128
+ }
129
+
149
130
  return this.data[key] = val;
150
131
  }
151
132
 
152
133
  getData(key, def) {
134
+ if (this.data == null) {
135
+ this.data = Object.create(null);
136
+ }
137
+
153
138
  let val = this.data[key];
154
139
  if (val === undefined && def !== undefined) val = this.data[key] = def;
155
140
  return val;
@@ -164,7 +149,7 @@ class NodePath {
164
149
  }
165
150
 
166
151
  set(key, node) {
167
- t().validate(this.node, key, node);
152
+ t.validate(this.node, key, node);
168
153
  this.node[key] = node;
169
154
  }
170
155
 
@@ -187,7 +172,57 @@ class NodePath {
187
172
  }
188
173
 
189
174
  toString() {
190
- return (0, _generator().default)(this.node).code;
175
+ return (0, _generator.default)(this.node).code;
176
+ }
177
+
178
+ get inList() {
179
+ return !!this.listKey;
180
+ }
181
+
182
+ set inList(inList) {
183
+ if (!inList) {
184
+ this.listKey = null;
185
+ }
186
+ }
187
+
188
+ get parentKey() {
189
+ return this.listKey || this.key;
190
+ }
191
+
192
+ get shouldSkip() {
193
+ return !!(this._traverseFlags & SHOULD_SKIP);
194
+ }
195
+
196
+ set shouldSkip(v) {
197
+ if (v) {
198
+ this._traverseFlags |= SHOULD_SKIP;
199
+ } else {
200
+ this._traverseFlags &= ~SHOULD_SKIP;
201
+ }
202
+ }
203
+
204
+ get shouldStop() {
205
+ return !!(this._traverseFlags & SHOULD_STOP);
206
+ }
207
+
208
+ set shouldStop(v) {
209
+ if (v) {
210
+ this._traverseFlags |= SHOULD_STOP;
211
+ } else {
212
+ this._traverseFlags &= ~SHOULD_STOP;
213
+ }
214
+ }
215
+
216
+ get removed() {
217
+ return !!(this._traverseFlags & REMOVED);
218
+ }
219
+
220
+ set removed(v) {
221
+ if (v) {
222
+ this._traverseFlags |= REMOVED;
223
+ } else {
224
+ this._traverseFlags &= ~REMOVED;
225
+ }
191
226
  }
192
227
 
193
228
  }
@@ -195,9 +230,9 @@ class NodePath {
195
230
  exports.default = NodePath;
196
231
  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
232
 
198
- for (const type of t().TYPES) {
233
+ for (const type of t.TYPES) {
199
234
  const typeKey = `is${type}`;
200
- const fn = t()[typeKey];
235
+ const fn = t[typeKey];
201
236
 
202
237
  NodePath.prototype[typeKey] = function (opts) {
203
238
  return fn(this.node, opts);
@@ -212,7 +247,7 @@ for (const type of t().TYPES) {
212
247
 
213
248
  for (const type of Object.keys(virtualTypes)) {
214
249
  if (type[0] === "_") continue;
215
- if (t().TYPES.indexOf(type) < 0) t().TYPES.push(type);
250
+ if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type);
216
251
  const virtualType = virtualTypes[type];
217
252
 
218
253
  NodePath.prototype[`is${type}`] = function (opts) {
@@ -12,24 +12,16 @@ 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
 
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; }
19
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
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
  }
@@ -5,19 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = _default;
7
7
 
8
- function t() {
9
- const data = _interopRequireWildcard(require("@babel/types"));
10
-
11
- t = function () {
12
- return data;
13
- };
14
-
15
- return data;
16
- }
8
+ var t = _interopRequireWildcard(require("@babel/types"));
17
9
 
18
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
19
11
 
20
- 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; }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
21
13
 
22
14
  function _default(node) {
23
15
  if (!this.isReferenced()) return;
@@ -32,9 +24,9 @@ function _default(node) {
32
24
  }
33
25
 
34
26
  if (node.name === "undefined") {
35
- return t().voidTypeAnnotation();
27
+ return t.voidTypeAnnotation();
36
28
  } else if (node.name === "NaN" || node.name === "Infinity") {
37
- return t().numberTypeAnnotation();
29
+ return t.numberTypeAnnotation();
38
30
  } else if (node.name === "arguments") {}
39
31
  }
40
32
 
@@ -59,7 +51,7 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) {
59
51
  }
60
52
 
61
53
  if (types.length) {
62
- return t().createUnionTypeAnnotation(types);
54
+ return t.createUnionTypeAnnotation(types);
63
55
  }
64
56
  }
65
57
 
@@ -97,8 +89,8 @@ function inferAnnotationFromBinaryExpression(name, path) {
97
89
  return target.getTypeAnnotation();
98
90
  }
99
91
 
100
- if (t().BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
101
- return t().numberTypeAnnotation();
92
+ if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
93
+ return t.numberTypeAnnotation();
102
94
  }
103
95
 
104
96
  return;
@@ -128,7 +120,7 @@ function inferAnnotationFromBinaryExpression(name, path) {
128
120
  if (!typePath.isLiteral()) return;
129
121
  const typeValue = typePath.node.value;
130
122
  if (typeof typeValue !== "string") return;
131
- return t().createTypeAnnotationBasedOnTypeof(typeValue);
123
+ return t.createTypeAnnotationBasedOnTypeof(typeValue);
132
124
  }
133
125
 
134
126
  function getParentConditionalPath(binding, path, name) {
@@ -174,7 +166,7 @@ function getConditionalAnnotation(binding, path, name) {
174
166
 
175
167
  if (types.length) {
176
168
  return {
177
- typeAnnotation: t().createUnionTypeAnnotation(types),
169
+ typeAnnotation: t.createUnionTypeAnnotation(types),
178
170
  ifStatement
179
171
  };
180
172
  }
@@ -33,15 +33,7 @@ Object.defineProperty(exports, "Identifier", {
33
33
  }
34
34
  });
35
35
 
36
- function t() {
37
- const data = _interopRequireWildcard(require("@babel/types"));
38
-
39
- t = function () {
40
- return data;
41
- };
42
-
43
- return data;
44
- }
36
+ var t = _interopRequireWildcard(require("@babel/types"));
45
37
 
46
38
  var _infererReference = _interopRequireDefault(require("./inferer-reference"));
47
39
 
@@ -49,7 +41,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
49
41
 
50
42
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
51
43
 
52
- 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; }
44
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
53
45
 
54
46
  function VariableDeclarator() {
55
47
  const id = this.get("id");
@@ -76,55 +68,55 @@ TypeCastExpression.validParent = true;
76
68
 
77
69
  function NewExpression(node) {
78
70
  if (this.get("callee").isIdentifier()) {
79
- return t().genericTypeAnnotation(node.callee);
71
+ return t.genericTypeAnnotation(node.callee);
80
72
  }
81
73
  }
82
74
 
83
75
  function TemplateLiteral() {
84
- return t().stringTypeAnnotation();
76
+ return t.stringTypeAnnotation();
85
77
  }
86
78
 
87
79
  function UnaryExpression(node) {
88
80
  const operator = node.operator;
89
81
 
90
82
  if (operator === "void") {
91
- return t().voidTypeAnnotation();
92
- } else if (t().NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
93
- return t().numberTypeAnnotation();
94
- } else if (t().STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
95
- return t().stringTypeAnnotation();
96
- } else if (t().BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
97
- return t().booleanTypeAnnotation();
83
+ return t.voidTypeAnnotation();
84
+ } else if (t.NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
85
+ return t.numberTypeAnnotation();
86
+ } else if (t.STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
87
+ return t.stringTypeAnnotation();
88
+ } else if (t.BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
89
+ return t.booleanTypeAnnotation();
98
90
  }
99
91
  }
100
92
 
101
93
  function BinaryExpression(node) {
102
94
  const operator = node.operator;
103
95
 
104
- if (t().NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
105
- return t().numberTypeAnnotation();
106
- } else if (t().BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
107
- return t().booleanTypeAnnotation();
96
+ if (t.NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
97
+ return t.numberTypeAnnotation();
98
+ } else if (t.BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
99
+ return t.booleanTypeAnnotation();
108
100
  } else if (operator === "+") {
109
101
  const right = this.get("right");
110
102
  const left = this.get("left");
111
103
 
112
104
  if (left.isBaseType("number") && right.isBaseType("number")) {
113
- return t().numberTypeAnnotation();
105
+ return t.numberTypeAnnotation();
114
106
  } else if (left.isBaseType("string") || right.isBaseType("string")) {
115
- return t().stringTypeAnnotation();
107
+ return t.stringTypeAnnotation();
116
108
  }
117
109
 
118
- return t().unionTypeAnnotation([t().stringTypeAnnotation(), t().numberTypeAnnotation()]);
110
+ return t.unionTypeAnnotation([t.stringTypeAnnotation(), t.numberTypeAnnotation()]);
119
111
  }
120
112
  }
121
113
 
122
114
  function LogicalExpression() {
123
- return t().createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
115
+ return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
124
116
  }
125
117
 
126
118
  function ConditionalExpression() {
127
- return t().createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
119
+ return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
128
120
  }
129
121
 
130
122
  function SequenceExpression() {
@@ -143,36 +135,36 @@ function UpdateExpression(node) {
143
135
  const operator = node.operator;
144
136
 
145
137
  if (operator === "++" || operator === "--") {
146
- return t().numberTypeAnnotation();
138
+ return t.numberTypeAnnotation();
147
139
  }
148
140
  }
149
141
 
150
142
  function StringLiteral() {
151
- return t().stringTypeAnnotation();
143
+ return t.stringTypeAnnotation();
152
144
  }
153
145
 
154
146
  function NumericLiteral() {
155
- return t().numberTypeAnnotation();
147
+ return t.numberTypeAnnotation();
156
148
  }
157
149
 
158
150
  function BooleanLiteral() {
159
- return t().booleanTypeAnnotation();
151
+ return t.booleanTypeAnnotation();
160
152
  }
161
153
 
162
154
  function NullLiteral() {
163
- return t().nullLiteralTypeAnnotation();
155
+ return t.nullLiteralTypeAnnotation();
164
156
  }
165
157
 
166
158
  function RegExpLiteral() {
167
- return t().genericTypeAnnotation(t().identifier("RegExp"));
159
+ return t.genericTypeAnnotation(t.identifier("RegExp"));
168
160
  }
169
161
 
170
162
  function ObjectExpression() {
171
- return t().genericTypeAnnotation(t().identifier("Object"));
163
+ return t.genericTypeAnnotation(t.identifier("Object"));
172
164
  }
173
165
 
174
166
  function ArrayExpression() {
175
- return t().genericTypeAnnotation(t().identifier("Array"));
167
+ return t.genericTypeAnnotation(t.identifier("Array"));
176
168
  }
177
169
 
178
170
  function RestElement() {
@@ -182,13 +174,13 @@ function RestElement() {
182
174
  RestElement.validParent = true;
183
175
 
184
176
  function Func() {
185
- return t().genericTypeAnnotation(t().identifier("Function"));
177
+ return t.genericTypeAnnotation(t.identifier("Function"));
186
178
  }
187
179
 
188
- const isArrayFrom = t().buildMatchMemberExpression("Array.from");
189
- const isObjectKeys = t().buildMatchMemberExpression("Object.keys");
190
- const isObjectValues = t().buildMatchMemberExpression("Object.values");
191
- const isObjectEntries = t().buildMatchMemberExpression("Object.entries");
180
+ const isArrayFrom = t.buildMatchMemberExpression("Array.from");
181
+ const isObjectKeys = t.buildMatchMemberExpression("Object.keys");
182
+ const isObjectValues = t.buildMatchMemberExpression("Object.values");
183
+ const isObjectEntries = t.buildMatchMemberExpression("Object.entries");
192
184
 
193
185
  function CallExpression() {
194
186
  const {
@@ -196,11 +188,11 @@ function CallExpression() {
196
188
  } = this.node;
197
189
 
198
190
  if (isObjectKeys(callee)) {
199
- return t().arrayTypeAnnotation(t().stringTypeAnnotation());
191
+ return t.arrayTypeAnnotation(t.stringTypeAnnotation());
200
192
  } else if (isArrayFrom(callee) || isObjectValues(callee)) {
201
- return t().arrayTypeAnnotation(t().anyTypeAnnotation());
193
+ return t.arrayTypeAnnotation(t.anyTypeAnnotation());
202
194
  } else if (isObjectEntries(callee)) {
203
- return t().arrayTypeAnnotation(t().tupleTypeAnnotation([t().stringTypeAnnotation(), t().anyTypeAnnotation()]));
195
+ return t.arrayTypeAnnotation(t.tupleTypeAnnotation([t.stringTypeAnnotation(), t.anyTypeAnnotation()]));
204
196
  }
205
197
 
206
198
  return resolveCall(this.get("callee"));
@@ -216,9 +208,9 @@ function resolveCall(callee) {
216
208
  if (callee.isFunction()) {
217
209
  if (callee.is("async")) {
218
210
  if (callee.is("generator")) {
219
- return t().genericTypeAnnotation(t().identifier("AsyncIterator"));
211
+ return t.genericTypeAnnotation(t.identifier("AsyncIterator"));
220
212
  } else {
221
- return t().genericTypeAnnotation(t().identifier("Promise"));
213
+ return t.genericTypeAnnotation(t.identifier("Promise"));
222
214
  }
223
215
  } else {
224
216
  if (callee.node.returnType) {
@@ -24,34 +24,18 @@ exports.isConstantExpression = isConstantExpression;
24
24
  exports.isInStrictMode = isInStrictMode;
25
25
  exports.is = void 0;
26
26
 
27
- function _includes() {
28
- const data = _interopRequireDefault(require("lodash/includes"));
27
+ var _includes = _interopRequireDefault(require("lodash/includes"));
29
28
 
30
- _includes = function () {
31
- return data;
32
- };
33
-
34
- return data;
35
- }
36
-
37
- function t() {
38
- const data = _interopRequireWildcard(require("@babel/types"));
39
-
40
- t = function () {
41
- return data;
42
- };
43
-
44
- return data;
45
- }
29
+ var t = _interopRequireWildcard(require("@babel/types"));
46
30
 
47
31
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
48
32
 
49
- 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; }
33
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; 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; }
50
34
 
51
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
52
36
 
53
37
  function matchesPattern(pattern, allowPartial) {
54
- return t().matchesPattern(this.node, pattern, allowPartial);
38
+ return t.matchesPattern(this.node, pattern, allowPartial);
55
39
  }
56
40
 
57
41
  function has(key) {
@@ -80,7 +64,7 @@ function equals(key, value) {
80
64
  }
81
65
 
82
66
  function isNodeType(type) {
83
- return t().isType(this.type, type);
67
+ return t.isType(this.type, type);
84
68
  }
85
69
 
86
70
  function canHaveVariableDeclarationOrExpression() {
@@ -93,9 +77,9 @@ function canSwapBetweenExpressionAndStatement(replacement) {
93
77
  }
94
78
 
95
79
  if (this.isExpression()) {
96
- return t().isBlockStatement(replacement);
80
+ return t.isBlockStatement(replacement);
97
81
  } else if (this.isBlockStatement()) {
98
- return t().isExpression(replacement);
82
+ return t.isExpression(replacement);
99
83
  }
100
84
 
101
85
  return false;
@@ -123,10 +107,10 @@ function isCompletionRecord(allowInsideFunction) {
123
107
  }
124
108
 
125
109
  function isStatementOrBlock() {
126
- if (this.parentPath.isLabeledStatement() || t().isBlockStatement(this.container)) {
110
+ if (this.parentPath.isLabeledStatement() || t.isBlockStatement(this.container)) {
127
111
  return false;
128
112
  } else {
129
- return (0, _includes().default)(t().STATEMENT_OR_BLOCK_KEYS, this.key);
113
+ return (0, _includes.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key);
130
114
  }
131
115
  }
132
116
 
@@ -278,7 +262,7 @@ function _guessExecutionStatusRelativeTo(target) {
278
262
  return divergence.target.key > divergence.this.key ? "before" : "after";
279
263
  }
280
264
 
281
- const keys = t().VISITOR_KEYS[commonPath.type];
265
+ const keys = t.VISITOR_KEYS[commonPath.type];
282
266
  const keyPosition = {
283
267
  this: keys.indexOf(divergence.this.parentKey),
284
268
  target: keys.indexOf(divergence.target.parentKey)
@@ -351,7 +335,7 @@ function _resolve(dangerous, resolved) {
351
335
  return this.get("expression").resolve(dangerous, resolved);
352
336
  } else if (dangerous && this.isMemberExpression()) {
353
337
  const targetKey = this.toComputedKey();
354
- if (!t().isLiteral(targetKey)) return;
338
+ if (!t.isLiteral(targetKey)) return;
355
339
  const targetName = targetKey.value;
356
340
  const target = this.get("object").resolve(dangerous, resolved);
357
341