@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.

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