ast-types 0.13.4 → 0.15.0
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.
- package/.github/workflows/main.yml +1 -1
- package/README.md +1 -1
- package/def/babel-core.js +20 -59
- package/def/babel.js +15 -2
- package/def/core.js +8 -8
- package/def/es-proposals.js +49 -20
- package/def/{es7.d.ts → es2016.d.ts} +0 -0
- package/def/es2016.js +14 -0
- package/def/es2017.d.ts +2 -0
- package/def/es2017.js +20 -0
- package/def/es2018.d.ts +2 -0
- package/def/{es7.js → es2018.js} +13 -13
- package/def/es2019.d.ts +2 -0
- package/def/es2019.js +17 -0
- package/def/es2020.js +36 -3
- package/def/es2021.d.ts +2 -0
- package/def/es2021.js +13 -0
- package/def/es2022.d.ts +2 -0
- package/def/es2022.js +16 -0
- package/def/es6.js +48 -22
- package/def/esprima.js +4 -4
- package/def/flow.js +85 -17
- package/def/jsx.js +27 -22
- package/def/operators/core.d.ts +5 -0
- package/def/operators/core.js +25 -0
- package/def/operators/es2016.d.ts +5 -0
- package/def/operators/es2016.js +19 -0
- package/def/operators/es2020.d.ts +5 -0
- package/def/operators/es2020.js +15 -0
- package/def/operators/es2021.d.ts +5 -0
- package/def/operators/es2021.js +18 -0
- package/def/type-annotations.js +2 -2
- package/def/typescript.js +11 -4
- package/fork.js +5 -5
- package/gen/builders.d.ts +489 -258
- package/gen/kinds.d.ts +61 -36
- package/gen/namedTypes.d.ts +334 -166
- package/gen/visitor.d.ts +47 -22
- package/lib/equiv.js +1 -1
- package/lib/node-path.js +3 -3
- package/lib/path-visitor.js +2 -2
- package/lib/path.d.ts +3 -3
- package/lib/path.js +1 -1
- package/lib/scope.d.ts +3 -2
- package/lib/scope.js +63 -26
- package/lib/shared.js +1 -1
- package/lib/types.js +6 -6
- package/main.js +9 -19
- package/package.json +15 -15
package/def/es6.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var core_1 = tslib_1.__importDefault(require("./core"));
|
|
5
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
6
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
4
|
+
var core_1 = (0, tslib_1.__importDefault)(require("./core"));
|
|
5
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
6
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
7
7
|
function default_1(fork) {
|
|
8
8
|
fork.use(core_1.default);
|
|
9
9
|
var types = fork.use(types_1.default);
|
|
@@ -14,7 +14,7 @@ function default_1(fork) {
|
|
|
14
14
|
.field("generator", Boolean, defaults["false"])
|
|
15
15
|
.field("expression", Boolean, defaults["false"])
|
|
16
16
|
.field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
|
|
17
|
-
//
|
|
17
|
+
// Legacy
|
|
18
18
|
.field("rest", or(def("Identifier"), null), defaults["null"]);
|
|
19
19
|
// The ESTree way of representing a ...rest parameter.
|
|
20
20
|
def("RestElement")
|
|
@@ -28,11 +28,11 @@ function default_1(fork) {
|
|
|
28
28
|
.build("argument")
|
|
29
29
|
.field("argument", def("Pattern"));
|
|
30
30
|
def("FunctionDeclaration")
|
|
31
|
-
.build("id", "params", "body", "generator", "expression")
|
|
31
|
+
.build("id", "params", "body", "generator", "expression")
|
|
32
|
+
// May be `null` in the context of `export default function () {}`
|
|
33
|
+
.field("id", or(def("Identifier"), null));
|
|
32
34
|
def("FunctionExpression")
|
|
33
35
|
.build("id", "params", "body", "generator", "expression");
|
|
34
|
-
// The Parser API calls this ArrowExpression, but Esprima and all other
|
|
35
|
-
// actual parsers use ArrowFunctionExpression.
|
|
36
36
|
def("ArrowFunctionExpression")
|
|
37
37
|
.bases("Function", "Expression")
|
|
38
38
|
.build("params", "body", "expression")
|
|
@@ -95,14 +95,6 @@ function default_1(fork) {
|
|
|
95
95
|
.bases("Pattern")
|
|
96
96
|
.build("elements")
|
|
97
97
|
.field("elements", [or(def("Pattern"), null)]);
|
|
98
|
-
def("MethodDefinition")
|
|
99
|
-
.bases("Declaration")
|
|
100
|
-
.build("kind", "key", "value", "static")
|
|
101
|
-
.field("kind", or("constructor", "method", "get", "set"))
|
|
102
|
-
.field("key", def("Expression"))
|
|
103
|
-
.field("value", def("Function"))
|
|
104
|
-
.field("computed", Boolean, defaults["false"])
|
|
105
|
-
.field("static", Boolean, defaults["false"]);
|
|
106
98
|
def("SpreadElement")
|
|
107
99
|
.bases("Node")
|
|
108
100
|
.build("argument")
|
|
@@ -124,6 +116,14 @@ function default_1(fork) {
|
|
|
124
116
|
.build("left", "right")
|
|
125
117
|
.field("left", def("Pattern"))
|
|
126
118
|
.field("right", def("Expression"));
|
|
119
|
+
def("MethodDefinition")
|
|
120
|
+
.bases("Declaration")
|
|
121
|
+
.build("kind", "key", "value", "static")
|
|
122
|
+
.field("kind", or("constructor", "method", "get", "set"))
|
|
123
|
+
.field("key", def("Expression"))
|
|
124
|
+
.field("value", def("Function"))
|
|
125
|
+
.field("computed", Boolean, defaults["false"])
|
|
126
|
+
.field("static", Boolean, defaults["false"]);
|
|
127
127
|
var ClassBodyElement = or(def("MethodDefinition"), def("VariableDeclarator"), def("ClassPropertyDefinition"), def("ClassProperty"));
|
|
128
128
|
def("ClassProperty")
|
|
129
129
|
.bases("Declaration")
|
|
@@ -151,6 +151,9 @@ function default_1(fork) {
|
|
|
151
151
|
.field("id", or(def("Identifier"), null), defaults["null"])
|
|
152
152
|
.field("body", def("ClassBody"))
|
|
153
153
|
.field("superClass", or(def("Expression"), null), defaults["null"]);
|
|
154
|
+
def("Super")
|
|
155
|
+
.bases("Expression")
|
|
156
|
+
.build();
|
|
154
157
|
// Specifier and ModuleSpecifier are abstract non-standard types
|
|
155
158
|
// introduced for definitional convenience.
|
|
156
159
|
def("Specifier").bases("Node");
|
|
@@ -169,19 +172,19 @@ function default_1(fork) {
|
|
|
169
172
|
// optional in the Babel/Acorn AST format.
|
|
170
173
|
.field("id", or(def("Identifier"), null), defaults["null"])
|
|
171
174
|
.field("name", or(def("Identifier"), null), defaults["null"]);
|
|
172
|
-
// Like ModuleSpecifier, except type:"ImportSpecifier" and buildable.
|
|
173
175
|
// import {<id [as name]>} from ...;
|
|
174
176
|
def("ImportSpecifier")
|
|
175
177
|
.bases("ModuleSpecifier")
|
|
176
|
-
.build("
|
|
177
|
-
|
|
178
|
-
def("ImportNamespaceSpecifier")
|
|
179
|
-
.bases("ModuleSpecifier")
|
|
180
|
-
.build("id");
|
|
178
|
+
.build("imported", "local")
|
|
179
|
+
.field("imported", def("Identifier"));
|
|
181
180
|
// import <id> from ...;
|
|
182
181
|
def("ImportDefaultSpecifier")
|
|
183
182
|
.bases("ModuleSpecifier")
|
|
184
|
-
.build("
|
|
183
|
+
.build("local");
|
|
184
|
+
// import <* as id> from ...;
|
|
185
|
+
def("ImportNamespaceSpecifier")
|
|
186
|
+
.bases("ModuleSpecifier")
|
|
187
|
+
.build("local");
|
|
185
188
|
def("ImportDeclaration")
|
|
186
189
|
.bases("Declaration")
|
|
187
190
|
.build("specifiers", "source", "importKind")
|
|
@@ -190,6 +193,24 @@ function default_1(fork) {
|
|
|
190
193
|
.field("importKind", or("value", "type"), function () {
|
|
191
194
|
return "value";
|
|
192
195
|
});
|
|
196
|
+
def("ExportNamedDeclaration")
|
|
197
|
+
.bases("Declaration")
|
|
198
|
+
.build("declaration", "specifiers", "source")
|
|
199
|
+
.field("declaration", or(def("Declaration"), null))
|
|
200
|
+
.field("specifiers", [def("ExportSpecifier")], defaults.emptyArray)
|
|
201
|
+
.field("source", or(def("Literal"), null), defaults["null"]);
|
|
202
|
+
def("ExportSpecifier")
|
|
203
|
+
.bases("ModuleSpecifier")
|
|
204
|
+
.build("local", "exported")
|
|
205
|
+
.field("exported", def("Identifier"));
|
|
206
|
+
def("ExportDefaultDeclaration")
|
|
207
|
+
.bases("Declaration")
|
|
208
|
+
.build("declaration")
|
|
209
|
+
.field("declaration", or(def("Declaration"), def("Expression")));
|
|
210
|
+
def("ExportAllDeclaration")
|
|
211
|
+
.bases("Declaration")
|
|
212
|
+
.build("source")
|
|
213
|
+
.field("source", def("Literal"));
|
|
193
214
|
def("TaggedTemplateExpression")
|
|
194
215
|
.bases("Expression")
|
|
195
216
|
.build("tag", "quasi")
|
|
@@ -205,6 +226,11 @@ function default_1(fork) {
|
|
|
205
226
|
.build("value", "tail")
|
|
206
227
|
.field("value", { "cooked": String, "raw": String })
|
|
207
228
|
.field("tail", Boolean);
|
|
229
|
+
def("MetaProperty")
|
|
230
|
+
.bases("Expression")
|
|
231
|
+
.build("meta", "property")
|
|
232
|
+
.field("meta", def("Identifier"))
|
|
233
|
+
.field("property", def("Identifier"));
|
|
208
234
|
}
|
|
209
235
|
exports.default = default_1;
|
|
210
236
|
module.exports = exports["default"];
|
package/def/esprima.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var
|
|
5
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
6
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
4
|
+
var es_proposals_1 = (0, tslib_1.__importDefault)(require("./es-proposals"));
|
|
5
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
6
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
7
7
|
function default_1(fork) {
|
|
8
|
-
fork.use(
|
|
8
|
+
fork.use(es_proposals_1.default);
|
|
9
9
|
var types = fork.use(types_1.default);
|
|
10
10
|
var defaults = fork.use(shared_1.default).defaults;
|
|
11
11
|
var def = types.Type.def;
|
package/def/flow.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var
|
|
5
|
-
var type_annotations_1 = tslib_1.__importDefault(require("./type-annotations"));
|
|
6
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
7
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
4
|
+
var es_proposals_1 = (0, tslib_1.__importDefault)(require("./es-proposals"));
|
|
5
|
+
var type_annotations_1 = (0, tslib_1.__importDefault)(require("./type-annotations"));
|
|
6
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
7
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
8
8
|
function default_1(fork) {
|
|
9
|
-
fork.use(
|
|
9
|
+
fork.use(es_proposals_1.default);
|
|
10
10
|
fork.use(type_annotations_1.default);
|
|
11
11
|
var types = fork.use(types_1.default);
|
|
12
12
|
var def = types.Type.def;
|
|
@@ -28,9 +28,15 @@ function default_1(fork) {
|
|
|
28
28
|
def("VoidTypeAnnotation")
|
|
29
29
|
.bases("FlowType")
|
|
30
30
|
.build();
|
|
31
|
+
def("SymbolTypeAnnotation")
|
|
32
|
+
.bases("FlowType")
|
|
33
|
+
.build();
|
|
31
34
|
def("NumberTypeAnnotation")
|
|
32
35
|
.bases("FlowType")
|
|
33
36
|
.build();
|
|
37
|
+
def("BigIntTypeAnnotation")
|
|
38
|
+
.bases("FlowType")
|
|
39
|
+
.build();
|
|
34
40
|
def("NumberLiteralTypeAnnotation")
|
|
35
41
|
.bases("FlowType")
|
|
36
42
|
.build("value", "raw")
|
|
@@ -43,6 +49,11 @@ function default_1(fork) {
|
|
|
43
49
|
.build("value", "raw")
|
|
44
50
|
.field("value", Number)
|
|
45
51
|
.field("raw", String);
|
|
52
|
+
def("BigIntLiteralTypeAnnotation")
|
|
53
|
+
.bases("FlowType")
|
|
54
|
+
.build("value", "raw")
|
|
55
|
+
.field("value", null)
|
|
56
|
+
.field("raw", String);
|
|
46
57
|
def("StringTypeAnnotation")
|
|
47
58
|
.bases("FlowType")
|
|
48
59
|
.build();
|
|
@@ -92,7 +103,7 @@ function default_1(fork) {
|
|
|
92
103
|
def("FunctionTypeParam")
|
|
93
104
|
.bases("Node")
|
|
94
105
|
.build("name", "typeAnnotation", "optional")
|
|
95
|
-
.field("name", def("Identifier"))
|
|
106
|
+
.field("name", or(def("Identifier"), null))
|
|
96
107
|
.field("typeAnnotation", def("FlowType"))
|
|
97
108
|
.field("optional", Boolean);
|
|
98
109
|
def("ArrayTypeAnnotation")
|
|
@@ -128,7 +139,8 @@ function default_1(fork) {
|
|
|
128
139
|
.field("id", def("Identifier"))
|
|
129
140
|
.field("key", def("FlowType"))
|
|
130
141
|
.field("value", def("FlowType"))
|
|
131
|
-
.field("variance", LegacyVariance, defaults["null"])
|
|
142
|
+
.field("variance", LegacyVariance, defaults["null"])
|
|
143
|
+
.field("static", Boolean, defaults["false"]);
|
|
132
144
|
def("ObjectTypeCallProperty")
|
|
133
145
|
.bases("Node")
|
|
134
146
|
.build("value")
|
|
@@ -149,6 +161,17 @@ function default_1(fork) {
|
|
|
149
161
|
.build("object", "property")
|
|
150
162
|
.field("object", def("Identifier"))
|
|
151
163
|
.field("property", or(def("MemberTypeAnnotation"), def("GenericTypeAnnotation")));
|
|
164
|
+
def("IndexedAccessType")
|
|
165
|
+
.bases("FlowType")
|
|
166
|
+
.build("objectType", "indexType")
|
|
167
|
+
.field("objectType", def("FlowType"))
|
|
168
|
+
.field("indexType", def("FlowType"));
|
|
169
|
+
def("OptionalIndexedAccessType")
|
|
170
|
+
.bases("FlowType")
|
|
171
|
+
.build("objectType", "indexType", "optional")
|
|
172
|
+
.field("objectType", def("FlowType"))
|
|
173
|
+
.field("indexType", def("FlowType"))
|
|
174
|
+
.field('optional', Boolean);
|
|
152
175
|
def("UnionTypeAnnotation")
|
|
153
176
|
.bases("FlowType")
|
|
154
177
|
.build("types")
|
|
@@ -183,10 +206,11 @@ function default_1(fork) {
|
|
|
183
206
|
.field("params", [def("FlowType")]);
|
|
184
207
|
def("TypeParameter")
|
|
185
208
|
.bases("FlowType")
|
|
186
|
-
.build("name", "variance", "bound")
|
|
209
|
+
.build("name", "variance", "bound", "default")
|
|
187
210
|
.field("name", String)
|
|
188
211
|
.field("variance", LegacyVariance, defaults["null"])
|
|
189
|
-
.field("bound", or(def("TypeAnnotation"), null), defaults["null"])
|
|
212
|
+
.field("bound", or(def("TypeAnnotation"), null), defaults["null"])
|
|
213
|
+
.field("default", or(def("FlowType"), null), defaults["null"]);
|
|
190
214
|
def("ClassProperty")
|
|
191
215
|
.field("variance", LegacyVariance, defaults["null"]);
|
|
192
216
|
def("ClassImplements")
|
|
@@ -221,19 +245,20 @@ function default_1(fork) {
|
|
|
221
245
|
.field("id", def("Identifier"))
|
|
222
246
|
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
223
247
|
.field("right", def("FlowType"));
|
|
248
|
+
def("DeclareTypeAlias")
|
|
249
|
+
.bases("TypeAlias")
|
|
250
|
+
.build("id", "typeParameters", "right");
|
|
224
251
|
def("OpaqueType")
|
|
225
252
|
.bases("Declaration")
|
|
226
253
|
.build("id", "typeParameters", "impltype", "supertype")
|
|
227
254
|
.field("id", def("Identifier"))
|
|
228
255
|
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
229
256
|
.field("impltype", def("FlowType"))
|
|
230
|
-
.field("supertype", def("FlowType"));
|
|
231
|
-
def("DeclareTypeAlias")
|
|
232
|
-
.bases("TypeAlias")
|
|
233
|
-
.build("id", "typeParameters", "right");
|
|
257
|
+
.field("supertype", or(def("FlowType"), null));
|
|
234
258
|
def("DeclareOpaqueType")
|
|
235
|
-
.bases("
|
|
236
|
-
.build("id", "typeParameters", "supertype")
|
|
259
|
+
.bases("OpaqueType")
|
|
260
|
+
.build("id", "typeParameters", "supertype")
|
|
261
|
+
.field("impltype", or(def("FlowType"), null));
|
|
237
262
|
def("TypeCastExpression")
|
|
238
263
|
.bases("Expression")
|
|
239
264
|
.build("expression", "typeAnnotation")
|
|
@@ -250,7 +275,8 @@ function default_1(fork) {
|
|
|
250
275
|
def("DeclareFunction")
|
|
251
276
|
.bases("Statement")
|
|
252
277
|
.build("id")
|
|
253
|
-
.field("id", def("Identifier"))
|
|
278
|
+
.field("id", def("Identifier"))
|
|
279
|
+
.field("predicate", or(def("FlowPredicate"), null), defaults["null"]);
|
|
254
280
|
def("DeclareClass")
|
|
255
281
|
.bases("InterfaceDeclaration")
|
|
256
282
|
.build("id");
|
|
@@ -268,13 +294,17 @@ function default_1(fork) {
|
|
|
268
294
|
.build("default", "declaration", "specifiers", "source")
|
|
269
295
|
.field("default", Boolean)
|
|
270
296
|
.field("declaration", or(def("DeclareVariable"), def("DeclareFunction"), def("DeclareClass"), def("FlowType"), // Implies default.
|
|
271
|
-
|
|
297
|
+
def("TypeAlias"), // Implies named type
|
|
298
|
+
def("DeclareOpaqueType"), // Implies named opaque type
|
|
299
|
+
def("InterfaceDeclaration"), null))
|
|
272
300
|
.field("specifiers", [or(def("ExportSpecifier"), def("ExportBatchSpecifier"))], defaults.emptyArray)
|
|
273
301
|
.field("source", or(def("Literal"), null), defaults["null"]);
|
|
274
302
|
def("DeclareExportAllDeclaration")
|
|
275
303
|
.bases("Declaration")
|
|
276
304
|
.build("source")
|
|
277
305
|
.field("source", or(def("Literal"), null), defaults["null"]);
|
|
306
|
+
def("ImportDeclaration")
|
|
307
|
+
.field("importKind", or("value", "type", "typeof"), function () { return "value"; });
|
|
278
308
|
def("FlowPredicate").bases("Flow");
|
|
279
309
|
def("InferredPredicate")
|
|
280
310
|
.bases("FlowPredicate")
|
|
@@ -283,10 +313,48 @@ function default_1(fork) {
|
|
|
283
313
|
.bases("FlowPredicate")
|
|
284
314
|
.build("value")
|
|
285
315
|
.field("value", def("Expression"));
|
|
316
|
+
def("Function")
|
|
317
|
+
.field("predicate", or(def("FlowPredicate"), null), defaults["null"]);
|
|
286
318
|
def("CallExpression")
|
|
287
319
|
.field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]);
|
|
288
320
|
def("NewExpression")
|
|
289
321
|
.field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]);
|
|
322
|
+
// Enums
|
|
323
|
+
def("EnumDeclaration")
|
|
324
|
+
.bases("Declaration")
|
|
325
|
+
.build("id", "body")
|
|
326
|
+
.field("id", def("Identifier"))
|
|
327
|
+
.field("body", or(def("EnumBooleanBody"), def("EnumNumberBody"), def("EnumStringBody"), def("EnumSymbolBody")));
|
|
328
|
+
def("EnumBooleanBody")
|
|
329
|
+
.build("members", "explicitType")
|
|
330
|
+
.field("members", [def("EnumBooleanMember")])
|
|
331
|
+
.field("explicitType", Boolean);
|
|
332
|
+
def("EnumNumberBody")
|
|
333
|
+
.build("members", "explicitType")
|
|
334
|
+
.field("members", [def("EnumNumberMember")])
|
|
335
|
+
.field("explicitType", Boolean);
|
|
336
|
+
def("EnumStringBody")
|
|
337
|
+
.build("members", "explicitType")
|
|
338
|
+
.field("members", or([def("EnumStringMember")], [def("EnumDefaultedMember")]))
|
|
339
|
+
.field("explicitType", Boolean);
|
|
340
|
+
def("EnumSymbolBody")
|
|
341
|
+
.build("members")
|
|
342
|
+
.field("members", [def("EnumDefaultedMember")]);
|
|
343
|
+
def("EnumBooleanMember")
|
|
344
|
+
.build("id", "init")
|
|
345
|
+
.field("id", def("Identifier"))
|
|
346
|
+
.field("init", or(def("Literal"), Boolean));
|
|
347
|
+
def("EnumNumberMember")
|
|
348
|
+
.build("id", "init")
|
|
349
|
+
.field("id", def("Identifier"))
|
|
350
|
+
.field("init", def("Literal"));
|
|
351
|
+
def("EnumStringMember")
|
|
352
|
+
.build("id", "init")
|
|
353
|
+
.field("id", def("Identifier"))
|
|
354
|
+
.field("init", def("Literal"));
|
|
355
|
+
def("EnumDefaultedMember")
|
|
356
|
+
.build("id")
|
|
357
|
+
.field("id", def("Identifier"));
|
|
290
358
|
}
|
|
291
359
|
exports.default = default_1;
|
|
292
360
|
module.exports = exports["default"];
|
package/def/jsx.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var
|
|
5
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
6
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
4
|
+
var es_proposals_1 = (0, tslib_1.__importDefault)(require("./es-proposals"));
|
|
5
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
6
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
7
7
|
function default_1(fork) {
|
|
8
|
-
fork.use(
|
|
8
|
+
fork.use(es_proposals_1.default);
|
|
9
9
|
var types = fork.use(types_1.default);
|
|
10
10
|
var def = types.Type.def;
|
|
11
11
|
var or = types.Type.or;
|
|
@@ -16,6 +16,8 @@ function default_1(fork) {
|
|
|
16
16
|
.field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
|
|
17
17
|
.field("value", or(def("Literal"), // attr="value"
|
|
18
18
|
def("JSXExpressionContainer"), // attr={value}
|
|
19
|
+
def("JSXElement"), // attr=<div />
|
|
20
|
+
def("JSXFragment"), // attr=<></>
|
|
19
21
|
null // attr= or just attr
|
|
20
22
|
), defaults["null"]);
|
|
21
23
|
def("JSXIdentifier")
|
|
@@ -42,14 +44,15 @@ function default_1(fork) {
|
|
|
42
44
|
def("JSXExpressionContainer")
|
|
43
45
|
.bases("Expression")
|
|
44
46
|
.build("expression")
|
|
45
|
-
.field("expression", def("Expression"));
|
|
47
|
+
.field("expression", or(def("Expression"), def("JSXEmptyExpression")));
|
|
48
|
+
var JSXChildren = [or(def("JSXText"), def("JSXExpressionContainer"), def("JSXSpreadChild"), def("JSXElement"), def("JSXFragment"), def("Literal") // Legacy: Esprima should return JSXText instead.
|
|
49
|
+
)];
|
|
46
50
|
def("JSXElement")
|
|
47
51
|
.bases("Expression")
|
|
48
52
|
.build("openingElement", "closingElement", "children")
|
|
49
53
|
.field("openingElement", def("JSXOpeningElement"))
|
|
50
54
|
.field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
|
|
51
|
-
.field("children",
|
|
52
|
-
)], defaults.emptyArray)
|
|
55
|
+
.field("children", JSXChildren, defaults.emptyArray)
|
|
53
56
|
.field("name", JSXElementName, function () {
|
|
54
57
|
// Little-known fact: the `this` object inside a default function
|
|
55
58
|
// is none other than the partially-built object itself, and any
|
|
@@ -65,37 +68,39 @@ function default_1(fork) {
|
|
|
65
68
|
return this.openingElement.attributes;
|
|
66
69
|
}, true); // hidden from traversal
|
|
67
70
|
def("JSXOpeningElement")
|
|
68
|
-
.bases("Node")
|
|
71
|
+
.bases("Node")
|
|
69
72
|
.build("name", "attributes", "selfClosing")
|
|
70
73
|
.field("name", JSXElementName)
|
|
71
74
|
.field("attributes", JSXAttributes, defaults.emptyArray)
|
|
72
75
|
.field("selfClosing", Boolean, defaults["false"]);
|
|
73
76
|
def("JSXClosingElement")
|
|
74
|
-
.bases("Node")
|
|
77
|
+
.bases("Node")
|
|
75
78
|
.build("name")
|
|
76
79
|
.field("name", JSXElementName);
|
|
77
80
|
def("JSXFragment")
|
|
78
81
|
.bases("Expression")
|
|
79
|
-
.build("
|
|
80
|
-
.field("
|
|
81
|
-
.field("
|
|
82
|
-
.field("children",
|
|
83
|
-
)], defaults.emptyArray);
|
|
82
|
+
.build("openingFragment", "closingFragment", "children")
|
|
83
|
+
.field("openingFragment", def("JSXOpeningFragment"))
|
|
84
|
+
.field("closingFragment", def("JSXClosingFragment"))
|
|
85
|
+
.field("children", JSXChildren, defaults.emptyArray);
|
|
84
86
|
def("JSXOpeningFragment")
|
|
85
|
-
.bases("Node")
|
|
87
|
+
.bases("Node")
|
|
86
88
|
.build();
|
|
87
89
|
def("JSXClosingFragment")
|
|
88
|
-
.bases("Node")
|
|
90
|
+
.bases("Node")
|
|
89
91
|
.build();
|
|
90
92
|
def("JSXText")
|
|
91
93
|
.bases("Literal")
|
|
92
|
-
.build("value")
|
|
93
|
-
.field("value", String)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
.build("value", "raw")
|
|
95
|
+
.field("value", String)
|
|
96
|
+
.field("raw", String, function () {
|
|
97
|
+
return this.value;
|
|
98
|
+
});
|
|
99
|
+
def("JSXEmptyExpression")
|
|
100
|
+
.bases("Node")
|
|
101
|
+
.build();
|
|
97
102
|
def("JSXSpreadChild")
|
|
98
|
-
.bases("
|
|
103
|
+
.bases("Node")
|
|
99
104
|
.build("expression")
|
|
100
105
|
.field("expression", def("Expression"));
|
|
101
106
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function default_1() {
|
|
4
|
+
return {
|
|
5
|
+
BinaryOperators: [
|
|
6
|
+
"==", "!=", "===", "!==",
|
|
7
|
+
"<", "<=", ">", ">=",
|
|
8
|
+
"<<", ">>", ">>>",
|
|
9
|
+
"+", "-", "*", "/", "%",
|
|
10
|
+
"&",
|
|
11
|
+
"|", "^", "in",
|
|
12
|
+
"instanceof",
|
|
13
|
+
],
|
|
14
|
+
AssignmentOperators: [
|
|
15
|
+
"=", "+=", "-=", "*=", "/=", "%=",
|
|
16
|
+
"<<=", ">>=", ">>>=",
|
|
17
|
+
"|=", "^=", "&=",
|
|
18
|
+
],
|
|
19
|
+
LogicalOperators: [
|
|
20
|
+
"||", "&&",
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.default = default_1;
|
|
25
|
+
module.exports = exports["default"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var core_1 = (0, tslib_1.__importDefault)(require("./core"));
|
|
5
|
+
function default_1(fork) {
|
|
6
|
+
var result = fork.use(core_1.default);
|
|
7
|
+
// Exponentiation operators. Must run before BinaryOperators or
|
|
8
|
+
// AssignmentOperators are used (hence before fork.use(es6Def)).
|
|
9
|
+
// https://github.com/tc39/proposal-exponentiation-operator
|
|
10
|
+
if (result.BinaryOperators.indexOf("**") < 0) {
|
|
11
|
+
result.BinaryOperators.push("**");
|
|
12
|
+
}
|
|
13
|
+
if (result.AssignmentOperators.indexOf("**=") < 0) {
|
|
14
|
+
result.AssignmentOperators.push("**=");
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.default = default_1;
|
|
19
|
+
module.exports = exports["default"];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var es2016_1 = (0, tslib_1.__importDefault)(require("./es2016"));
|
|
5
|
+
function default_1(fork) {
|
|
6
|
+
var result = fork.use(es2016_1.default);
|
|
7
|
+
// Nullish coalescing. Must run before LogicalOperators is used.
|
|
8
|
+
// https://github.com/tc39/proposal-nullish-coalescing
|
|
9
|
+
if (result.LogicalOperators.indexOf("??") < 0) {
|
|
10
|
+
result.LogicalOperators.push("??");
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
exports.default = default_1;
|
|
15
|
+
module.exports = exports["default"];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var es2020_1 = (0, tslib_1.__importDefault)(require("./es2020"));
|
|
5
|
+
function default_1(fork) {
|
|
6
|
+
var result = fork.use(es2020_1.default);
|
|
7
|
+
// Logical assignment operators. Must run before AssignmentOperators is used.
|
|
8
|
+
// https://github.com/tc39/proposal-logical-assignment
|
|
9
|
+
result.LogicalOperators.forEach(function (op) {
|
|
10
|
+
var assignOp = op + "=";
|
|
11
|
+
if (result.AssignmentOperators.indexOf(assignOp) < 0) {
|
|
12
|
+
result.AssignmentOperators.push(assignOp);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
exports.default = default_1;
|
|
18
|
+
module.exports = exports["default"];
|
package/def/type-annotations.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
var tslib_1 = require("tslib");
|
|
9
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
10
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
9
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
10
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
11
11
|
function default_1(fork) {
|
|
12
12
|
var types = fork.use(types_1.default);
|
|
13
13
|
var def = types.Type.def;
|
package/def/typescript.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var babel_core_1 = tslib_1.__importDefault(require("./babel-core"));
|
|
5
|
-
var type_annotations_1 = tslib_1.__importDefault(require("./type-annotations"));
|
|
6
|
-
var types_1 = tslib_1.__importDefault(require("../lib/types"));
|
|
7
|
-
var shared_1 = tslib_1.__importDefault(require("../lib/shared"));
|
|
4
|
+
var babel_core_1 = (0, tslib_1.__importDefault)(require("./babel-core"));
|
|
5
|
+
var type_annotations_1 = (0, tslib_1.__importDefault)(require("./type-annotations"));
|
|
6
|
+
var types_1 = (0, tslib_1.__importDefault)(require("../lib/types"));
|
|
7
|
+
var shared_1 = (0, tslib_1.__importDefault)(require("../lib/shared"));
|
|
8
8
|
function default_1(fork) {
|
|
9
9
|
// Since TypeScript is parsed by Babylon, include the core Babylon types
|
|
10
10
|
// but omit the Flow-related types.
|
|
@@ -74,6 +74,7 @@ function default_1(fork) {
|
|
|
74
74
|
"TSUndefinedKeyword",
|
|
75
75
|
"TSUnknownKeyword",
|
|
76
76
|
"TSVoidKeyword",
|
|
77
|
+
"TSIntrinsicKeyword",
|
|
77
78
|
"TSThisType",
|
|
78
79
|
].forEach(function (keywordType) {
|
|
79
80
|
def(keywordType)
|
|
@@ -88,6 +89,12 @@ function default_1(fork) {
|
|
|
88
89
|
.bases("TSType")
|
|
89
90
|
.build("literal")
|
|
90
91
|
.field("literal", or(def("NumericLiteral"), def("StringLiteral"), def("BooleanLiteral"), def("TemplateLiteral"), def("UnaryExpression")));
|
|
92
|
+
def("TemplateLiteral")
|
|
93
|
+
// The TemplateLiteral type appears to be reused for TypeScript template
|
|
94
|
+
// literal types (instead of introducing a new TSTemplateLiteralType type),
|
|
95
|
+
// so we allow the templateLiteral.expressions array to be either all
|
|
96
|
+
// expressions or all TypeScript types.
|
|
97
|
+
.field("expressions", or([def("Expression")], [def("TSType")]));
|
|
91
98
|
["TSUnionType",
|
|
92
99
|
"TSIntersectionType",
|
|
93
100
|
].forEach(function (typeName) {
|
package/fork.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var types_1 = tslib_1.__importDefault(require("./lib/types"));
|
|
5
|
-
var path_visitor_1 = tslib_1.__importDefault(require("./lib/path-visitor"));
|
|
6
|
-
var equiv_1 = tslib_1.__importDefault(require("./lib/equiv"));
|
|
7
|
-
var path_1 = tslib_1.__importDefault(require("./lib/path"));
|
|
8
|
-
var node_path_1 = tslib_1.__importDefault(require("./lib/node-path"));
|
|
4
|
+
var types_1 = (0, tslib_1.__importDefault)(require("./lib/types"));
|
|
5
|
+
var path_visitor_1 = (0, tslib_1.__importDefault)(require("./lib/path-visitor"));
|
|
6
|
+
var equiv_1 = (0, tslib_1.__importDefault)(require("./lib/equiv"));
|
|
7
|
+
var path_1 = (0, tslib_1.__importDefault)(require("./lib/path"));
|
|
8
|
+
var node_path_1 = (0, tslib_1.__importDefault)(require("./lib/node-path"));
|
|
9
9
|
function default_1(defs) {
|
|
10
10
|
var fork = createFork();
|
|
11
11
|
var types = fork.use(types_1.default);
|