ast-types 0.11.3 → 0.11.7
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/def/es-proposals.js +33 -0
- package/def/es6.js +3 -0
- package/def/flow.js +64 -85
- package/def/type-annotations.js +61 -0
- package/def/typescript.js +18 -13
- package/main.js +2 -1
- package/package.json +5 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = function (fork) {
|
|
2
|
+
fork.use(require('./core'));
|
|
3
|
+
|
|
4
|
+
var types = fork.use(require("../lib/types"));
|
|
5
|
+
var Type = types.Type;
|
|
6
|
+
var def = types.Type.def;
|
|
7
|
+
var or = Type.or;
|
|
8
|
+
|
|
9
|
+
var shared = fork.use(require("../lib/shared"));
|
|
10
|
+
var defaults = shared.defaults;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// https://github.com/tc39/proposal-optional-chaining
|
|
14
|
+
// `a?.b` as per https://github.com/estree/estree/issues/146
|
|
15
|
+
def("OptionalMemberExpression")
|
|
16
|
+
.bases("MemberExpression")
|
|
17
|
+
.build("object", "property", "computed", "optional")
|
|
18
|
+
.field("optional", Boolean, defaults["true"])
|
|
19
|
+
|
|
20
|
+
// a?.b()
|
|
21
|
+
def("OptionalCallExpression")
|
|
22
|
+
.bases("CallExpression")
|
|
23
|
+
.build("callee", "arguments", "optional")
|
|
24
|
+
.field("optional", Boolean, defaults["true"])
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// https://github.com/tc39/proposal-nullish-coalescing
|
|
28
|
+
// `a ?? b` as per https://github.com/babel/babylon/pull/761/files
|
|
29
|
+
var LogicalOperator = or("||", "&&", "??");
|
|
30
|
+
|
|
31
|
+
def("LogicalExpression")
|
|
32
|
+
.field("operator", LogicalOperator)
|
|
33
|
+
};
|
package/def/es6.js
CHANGED
|
@@ -88,6 +88,9 @@ module.exports = function (fork) {
|
|
|
88
88
|
.field("shorthand", Boolean, defaults["false"])
|
|
89
89
|
.field("computed", Boolean, defaults["false"]);
|
|
90
90
|
|
|
91
|
+
def("ObjectProperty")
|
|
92
|
+
.field("shorthand", Boolean, defaults["false"]);
|
|
93
|
+
|
|
91
94
|
def("PropertyPattern")
|
|
92
95
|
.bases("Pattern")
|
|
93
96
|
.build("key", "pattern")
|
package/def/flow.js
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
2
|
fork.use(require("./es7"));
|
|
3
|
+
fork.use(require("./type-annotations"));
|
|
3
4
|
|
|
4
5
|
var types = fork.use(require("../lib/types"));
|
|
5
6
|
var def = types.Type.def;
|
|
6
7
|
var or = types.Type.or;
|
|
7
8
|
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
8
9
|
|
|
9
|
-
//
|
|
10
|
-
|
|
10
|
+
// Base types
|
|
11
|
+
|
|
12
|
+
def("Flow").bases("Node");
|
|
13
|
+
def("FlowType").bases("Flow");
|
|
14
|
+
|
|
15
|
+
// Type annotations
|
|
11
16
|
|
|
12
17
|
def("AnyTypeAnnotation")
|
|
13
|
-
.bases("
|
|
18
|
+
.bases("FlowType")
|
|
14
19
|
.build();
|
|
15
20
|
|
|
16
21
|
def("EmptyTypeAnnotation")
|
|
17
|
-
.bases("
|
|
22
|
+
.bases("FlowType")
|
|
18
23
|
.build();
|
|
19
24
|
|
|
20
25
|
def("MixedTypeAnnotation")
|
|
21
|
-
.bases("
|
|
26
|
+
.bases("FlowType")
|
|
22
27
|
.build();
|
|
23
28
|
|
|
24
29
|
def("VoidTypeAnnotation")
|
|
25
|
-
.bases("
|
|
30
|
+
.bases("FlowType")
|
|
26
31
|
.build();
|
|
27
32
|
|
|
28
33
|
def("NumberTypeAnnotation")
|
|
29
|
-
.bases("
|
|
34
|
+
.bases("FlowType")
|
|
30
35
|
.build();
|
|
31
36
|
|
|
32
37
|
def("NumberLiteralTypeAnnotation")
|
|
33
|
-
.bases("
|
|
38
|
+
.bases("FlowType")
|
|
34
39
|
.build("value", "raw")
|
|
35
40
|
.field("value", Number)
|
|
36
41
|
.field("raw", String);
|
|
@@ -38,27 +43,27 @@ module.exports = function (fork) {
|
|
|
38
43
|
// Babylon 6 differs in AST from Flow
|
|
39
44
|
// same as NumberLiteralTypeAnnotation
|
|
40
45
|
def("NumericLiteralTypeAnnotation")
|
|
41
|
-
.bases("
|
|
46
|
+
.bases("FlowType")
|
|
42
47
|
.build("value", "raw")
|
|
43
48
|
.field("value", Number)
|
|
44
49
|
.field("raw", String);
|
|
45
50
|
|
|
46
51
|
def("StringTypeAnnotation")
|
|
47
|
-
.bases("
|
|
52
|
+
.bases("FlowType")
|
|
48
53
|
.build();
|
|
49
54
|
|
|
50
55
|
def("StringLiteralTypeAnnotation")
|
|
51
|
-
.bases("
|
|
56
|
+
.bases("FlowType")
|
|
52
57
|
.build("value", "raw")
|
|
53
58
|
.field("value", String)
|
|
54
59
|
.field("raw", String);
|
|
55
60
|
|
|
56
61
|
def("BooleanTypeAnnotation")
|
|
57
|
-
.bases("
|
|
62
|
+
.bases("FlowType")
|
|
58
63
|
.build();
|
|
59
64
|
|
|
60
65
|
def("BooleanLiteralTypeAnnotation")
|
|
61
|
-
.bases("
|
|
66
|
+
.bases("FlowType")
|
|
62
67
|
.build("value", "raw")
|
|
63
68
|
.field("value", Boolean)
|
|
64
69
|
.field("raw", String);
|
|
@@ -66,38 +71,38 @@ module.exports = function (fork) {
|
|
|
66
71
|
def("TypeAnnotation")
|
|
67
72
|
.bases("Node")
|
|
68
73
|
.build("typeAnnotation")
|
|
69
|
-
.field("typeAnnotation", def("
|
|
74
|
+
.field("typeAnnotation", def("FlowType"));
|
|
70
75
|
|
|
71
76
|
def("NullableTypeAnnotation")
|
|
72
|
-
.bases("
|
|
77
|
+
.bases("FlowType")
|
|
73
78
|
.build("typeAnnotation")
|
|
74
|
-
.field("typeAnnotation", def("
|
|
79
|
+
.field("typeAnnotation", def("FlowType"));
|
|
75
80
|
|
|
76
81
|
def("NullLiteralTypeAnnotation")
|
|
77
|
-
.bases("
|
|
82
|
+
.bases("FlowType")
|
|
78
83
|
.build();
|
|
79
84
|
|
|
80
85
|
def("NullTypeAnnotation")
|
|
81
|
-
.bases("
|
|
86
|
+
.bases("FlowType")
|
|
82
87
|
.build();
|
|
83
88
|
|
|
84
89
|
def("ThisTypeAnnotation")
|
|
85
|
-
.bases("
|
|
90
|
+
.bases("FlowType")
|
|
86
91
|
.build();
|
|
87
92
|
|
|
88
93
|
def("ExistsTypeAnnotation")
|
|
89
|
-
.bases("
|
|
94
|
+
.bases("FlowType")
|
|
90
95
|
.build();
|
|
91
96
|
|
|
92
97
|
def("ExistentialTypeParam")
|
|
93
|
-
.bases("
|
|
98
|
+
.bases("FlowType")
|
|
94
99
|
.build();
|
|
95
100
|
|
|
96
101
|
def("FunctionTypeAnnotation")
|
|
97
|
-
.bases("
|
|
102
|
+
.bases("FlowType")
|
|
98
103
|
.build("params", "returnType", "rest", "typeParameters")
|
|
99
104
|
.field("params", [def("FunctionTypeParam")])
|
|
100
|
-
.field("returnType", def("
|
|
105
|
+
.field("returnType", def("FlowType"))
|
|
101
106
|
.field("rest", or(def("FunctionTypeParam"), null))
|
|
102
107
|
.field("typeParameters", or(def("TypeParameterDeclaration"), null));
|
|
103
108
|
|
|
@@ -105,16 +110,16 @@ module.exports = function (fork) {
|
|
|
105
110
|
.bases("Node")
|
|
106
111
|
.build("name", "typeAnnotation", "optional")
|
|
107
112
|
.field("name", def("Identifier"))
|
|
108
|
-
.field("typeAnnotation", def("
|
|
113
|
+
.field("typeAnnotation", def("FlowType"))
|
|
109
114
|
.field("optional", Boolean);
|
|
110
115
|
|
|
111
116
|
def("ArrayTypeAnnotation")
|
|
112
|
-
.bases("
|
|
117
|
+
.bases("FlowType")
|
|
113
118
|
.build("elementType")
|
|
114
|
-
.field("elementType", def("
|
|
119
|
+
.field("elementType", def("FlowType"));
|
|
115
120
|
|
|
116
121
|
def("ObjectTypeAnnotation")
|
|
117
|
-
.bases("
|
|
122
|
+
.bases("FlowType")
|
|
118
123
|
.build("properties", "indexers", "callProperties")
|
|
119
124
|
.field("properties", [
|
|
120
125
|
or(def("ObjectTypeProperty"),
|
|
@@ -142,7 +147,7 @@ module.exports = function (fork) {
|
|
|
142
147
|
.bases("Node")
|
|
143
148
|
.build("key", "value", "optional")
|
|
144
149
|
.field("key", or(def("Literal"), def("Identifier")))
|
|
145
|
-
.field("value", def("
|
|
150
|
+
.field("value", def("FlowType"))
|
|
146
151
|
.field("optional", Boolean)
|
|
147
152
|
.field("variance", LegacyVariance, defaults["null"]);
|
|
148
153
|
|
|
@@ -150,8 +155,8 @@ module.exports = function (fork) {
|
|
|
150
155
|
.bases("Node")
|
|
151
156
|
.build("id", "key", "value")
|
|
152
157
|
.field("id", def("Identifier"))
|
|
153
|
-
.field("key", def("
|
|
154
|
-
.field("value", def("
|
|
158
|
+
.field("key", def("FlowType"))
|
|
159
|
+
.field("value", def("FlowType"))
|
|
155
160
|
.field("variance", LegacyVariance, defaults["null"]);
|
|
156
161
|
|
|
157
162
|
def("ObjectTypeCallProperty")
|
|
@@ -169,13 +174,13 @@ module.exports = function (fork) {
|
|
|
169
174
|
.field("id", def("Identifier"));
|
|
170
175
|
|
|
171
176
|
def("GenericTypeAnnotation")
|
|
172
|
-
.bases("
|
|
177
|
+
.bases("FlowType")
|
|
173
178
|
.build("id", "typeParameters")
|
|
174
179
|
.field("id", or(def("Identifier"), def("QualifiedTypeIdentifier")))
|
|
175
180
|
.field("typeParameters", or(def("TypeParameterInstantiation"), null));
|
|
176
181
|
|
|
177
182
|
def("MemberTypeAnnotation")
|
|
178
|
-
.bases("
|
|
183
|
+
.bases("FlowType")
|
|
179
184
|
.build("object", "property")
|
|
180
185
|
.field("object", def("Identifier"))
|
|
181
186
|
.field("property",
|
|
@@ -183,30 +188,24 @@ module.exports = function (fork) {
|
|
|
183
188
|
def("GenericTypeAnnotation")));
|
|
184
189
|
|
|
185
190
|
def("UnionTypeAnnotation")
|
|
186
|
-
.bases("
|
|
191
|
+
.bases("FlowType")
|
|
187
192
|
.build("types")
|
|
188
|
-
.field("types", [def("
|
|
193
|
+
.field("types", [def("FlowType")]);
|
|
189
194
|
|
|
190
195
|
def("IntersectionTypeAnnotation")
|
|
191
|
-
.bases("
|
|
196
|
+
.bases("FlowType")
|
|
192
197
|
.build("types")
|
|
193
|
-
.field("types", [def("
|
|
198
|
+
.field("types", [def("FlowType")]);
|
|
194
199
|
|
|
195
200
|
def("TypeofTypeAnnotation")
|
|
196
|
-
.bases("
|
|
201
|
+
.bases("FlowType")
|
|
197
202
|
.build("argument")
|
|
198
|
-
.field("argument", def("
|
|
203
|
+
.field("argument", def("FlowType"));
|
|
199
204
|
|
|
200
205
|
def("ObjectTypeSpreadProperty")
|
|
201
206
|
.bases("Node")
|
|
202
207
|
.build("argument")
|
|
203
|
-
.field("argument", def("
|
|
204
|
-
|
|
205
|
-
def("Identifier")
|
|
206
|
-
.field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
|
|
207
|
-
|
|
208
|
-
def("ObjectPattern")
|
|
209
|
-
.field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
|
|
208
|
+
.field("argument", def("FlowType"));
|
|
210
209
|
|
|
211
210
|
def("TypeParameterDeclaration")
|
|
212
211
|
.bases("Node")
|
|
@@ -216,10 +215,10 @@ module.exports = function (fork) {
|
|
|
216
215
|
def("TypeParameterInstantiation")
|
|
217
216
|
.bases("Node")
|
|
218
217
|
.build("params")
|
|
219
|
-
.field("params", [def("
|
|
218
|
+
.field("params", [def("FlowType")]);
|
|
220
219
|
|
|
221
220
|
def("TypeParameter")
|
|
222
|
-
.bases("
|
|
221
|
+
.bases("FlowType")
|
|
223
222
|
.build("name", "variance", "bound")
|
|
224
223
|
.field("name", String)
|
|
225
224
|
.field("variance", LegacyVariance, defaults["null"])
|
|
@@ -227,33 +226,9 @@ module.exports = function (fork) {
|
|
|
227
226
|
or(def("TypeAnnotation"), null),
|
|
228
227
|
defaults["null"]);
|
|
229
228
|
|
|
230
|
-
def("Function")
|
|
231
|
-
.field("returnType",
|
|
232
|
-
or(def("TypeAnnotation"), null),
|
|
233
|
-
defaults["null"])
|
|
234
|
-
.field("typeParameters",
|
|
235
|
-
or(def("TypeParameterDeclaration"), null),
|
|
236
|
-
defaults["null"]);
|
|
237
|
-
|
|
238
229
|
def("ClassProperty")
|
|
239
|
-
.build("key", "value", "typeAnnotation", "static")
|
|
240
|
-
.field("value", or(def("Expression"), null))
|
|
241
|
-
.field("typeAnnotation", or(def("TypeAnnotation"), null))
|
|
242
|
-
.field("static", Boolean, defaults["false"])
|
|
243
230
|
.field("variance", LegacyVariance, defaults["null"]);
|
|
244
231
|
|
|
245
|
-
["ClassDeclaration",
|
|
246
|
-
"ClassExpression",
|
|
247
|
-
].forEach(typeName => {
|
|
248
|
-
def(typeName)
|
|
249
|
-
.field("typeParameters",
|
|
250
|
-
or(def("TypeParameterDeclaration"), null),
|
|
251
|
-
defaults["null"])
|
|
252
|
-
.field("superTypeParameters",
|
|
253
|
-
or([def("GenericTypeAnnotation")], null),
|
|
254
|
-
defaults["null"]);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
232
|
def("ClassImplements")
|
|
258
233
|
.bases("Node")
|
|
259
234
|
.build("id")
|
|
@@ -263,13 +238,6 @@ module.exports = function (fork) {
|
|
|
263
238
|
or(def("TypeParameterInstantiation"), null),
|
|
264
239
|
defaults["null"]);
|
|
265
240
|
|
|
266
|
-
["ClassDeclaration",
|
|
267
|
-
"ClassExpression",
|
|
268
|
-
].forEach(typeName => {
|
|
269
|
-
def(typeName)
|
|
270
|
-
.field("implements", [def("ClassImplements")], defaults.emptyArray);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
241
|
def("InterfaceDeclaration")
|
|
274
242
|
.bases("Declaration")
|
|
275
243
|
.build("id", "body", "extends")
|
|
@@ -295,15 +263,15 @@ module.exports = function (fork) {
|
|
|
295
263
|
.build("id", "typeParameters", "right")
|
|
296
264
|
.field("id", def("Identifier"))
|
|
297
265
|
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
298
|
-
.field("right", def("
|
|
266
|
+
.field("right", def("FlowType"));
|
|
299
267
|
|
|
300
268
|
def("OpaqueType")
|
|
301
269
|
.bases("Declaration")
|
|
302
270
|
.build("id", "typeParameters", "impltype", "supertype")
|
|
303
271
|
.field("id", def("Identifier"))
|
|
304
272
|
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
305
|
-
.field("implType", def("
|
|
306
|
-
.field("superType", def("
|
|
273
|
+
.field("implType", def("FlowType"))
|
|
274
|
+
.field("superType", def("FlowType"));
|
|
307
275
|
|
|
308
276
|
def("DeclareTypeAlias")
|
|
309
277
|
.bases("TypeAlias")
|
|
@@ -320,9 +288,9 @@ module.exports = function (fork) {
|
|
|
320
288
|
.field("typeAnnotation", def("TypeAnnotation"));
|
|
321
289
|
|
|
322
290
|
def("TupleTypeAnnotation")
|
|
323
|
-
.bases("
|
|
291
|
+
.bases("FlowType")
|
|
324
292
|
.build("types")
|
|
325
|
-
.field("types", [def("
|
|
293
|
+
.field("types", [def("FlowType")]);
|
|
326
294
|
|
|
327
295
|
def("DeclareVariable")
|
|
328
296
|
.bases("Statement")
|
|
@@ -347,7 +315,7 @@ module.exports = function (fork) {
|
|
|
347
315
|
def("DeclareModuleExports")
|
|
348
316
|
.bases("Statement")
|
|
349
317
|
.build("typeAnnotation")
|
|
350
|
-
.field("typeAnnotation", def("
|
|
318
|
+
.field("typeAnnotation", def("TypeAnnotation"));
|
|
351
319
|
|
|
352
320
|
def("DeclareExportDeclaration")
|
|
353
321
|
.bases("Declaration")
|
|
@@ -357,7 +325,7 @@ module.exports = function (fork) {
|
|
|
357
325
|
def("DeclareVariable"),
|
|
358
326
|
def("DeclareFunction"),
|
|
359
327
|
def("DeclareClass"),
|
|
360
|
-
def("
|
|
328
|
+
def("FlowType"), // Implies default.
|
|
361
329
|
null
|
|
362
330
|
))
|
|
363
331
|
.field("specifiers", [or(
|
|
@@ -376,4 +344,15 @@ module.exports = function (fork) {
|
|
|
376
344
|
def("Literal"),
|
|
377
345
|
null
|
|
378
346
|
), defaults["null"]);
|
|
347
|
+
|
|
348
|
+
def("FlowPredicate").bases("Flow");
|
|
349
|
+
|
|
350
|
+
def("InferredPredicate")
|
|
351
|
+
.bases("FlowPredicate")
|
|
352
|
+
.build();
|
|
353
|
+
|
|
354
|
+
def("DeclaredPredicate")
|
|
355
|
+
.bases("FlowPredicate")
|
|
356
|
+
.build("value")
|
|
357
|
+
.field("value", def("Expression"));
|
|
379
358
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type annotation defs shared between Flow and TypeScript.
|
|
3
|
+
* These defs could not be defined in ./flow.js or ./typescript.js directly
|
|
4
|
+
* because they use the same name.
|
|
5
|
+
*/
|
|
6
|
+
module.exports = function (fork) {
|
|
7
|
+
var types = fork.use(require("../lib/types"));
|
|
8
|
+
var def = types.Type.def;
|
|
9
|
+
var or = types.Type.or;
|
|
10
|
+
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
11
|
+
|
|
12
|
+
var TypeAnnotation = or(
|
|
13
|
+
def("TypeAnnotation"),
|
|
14
|
+
def("TSTypeAnnotation"),
|
|
15
|
+
null
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
var TypeParamDecl = or(
|
|
19
|
+
def("TypeParameterDeclaration"),
|
|
20
|
+
def("TSTypeParameterDeclaration"),
|
|
21
|
+
null
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
def("Identifier")
|
|
25
|
+
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
|
|
26
|
+
|
|
27
|
+
def("ObjectPattern")
|
|
28
|
+
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
|
|
29
|
+
|
|
30
|
+
def("Function")
|
|
31
|
+
.field("returnType", TypeAnnotation, defaults["null"])
|
|
32
|
+
.field("typeParameters", TypeParamDecl, defaults["null"]);
|
|
33
|
+
|
|
34
|
+
def("ClassProperty")
|
|
35
|
+
.build("key", "value", "typeAnnotation", "static")
|
|
36
|
+
.field("value", or(def("Expression"), null))
|
|
37
|
+
.field("static", Boolean, defaults["false"])
|
|
38
|
+
.field("typeAnnotation", TypeAnnotation, defaults["null"]);
|
|
39
|
+
|
|
40
|
+
["ClassDeclaration",
|
|
41
|
+
"ClassExpression",
|
|
42
|
+
].forEach(typeName => {
|
|
43
|
+
def(typeName)
|
|
44
|
+
.field("typeParameters", TypeParamDecl, defaults["null"])
|
|
45
|
+
.field("superTypeParameters",
|
|
46
|
+
or(def("TypeParameterInstantiation"),
|
|
47
|
+
def("TSTypeParameterInstantiation"),
|
|
48
|
+
null),
|
|
49
|
+
defaults["null"]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
["ClassDeclaration",
|
|
53
|
+
"ClassExpression",
|
|
54
|
+
].forEach(typeName => {
|
|
55
|
+
def(typeName)
|
|
56
|
+
.field("implements",
|
|
57
|
+
or([def("ClassImplements")],
|
|
58
|
+
[def("TSExpressionWithTypeArguments")]),
|
|
59
|
+
defaults.emptyArray);
|
|
60
|
+
});
|
|
61
|
+
};
|
package/def/typescript.js
CHANGED
|
@@ -2,6 +2,7 @@ module.exports = function (fork) {
|
|
|
2
2
|
// Since TypeScript is parsed by Babylon, include the core Babylon types
|
|
3
3
|
// but omit the Flow-related types.
|
|
4
4
|
fork.use(require("./babel-core"));
|
|
5
|
+
fork.use(require("./type-annotations"));
|
|
5
6
|
|
|
6
7
|
var types = fork.use(require("../lib/types"));
|
|
7
8
|
var n = types.namedTypes;
|
|
@@ -31,6 +32,7 @@ module.exports = function (fork) {
|
|
|
31
32
|
|
|
32
33
|
def("TSTypeReference")
|
|
33
34
|
.bases("TSType")
|
|
35
|
+
.build("typeName", "typeParameters")
|
|
34
36
|
.field("typeName", IdOrQualifiedName)
|
|
35
37
|
.field("typeParameters",
|
|
36
38
|
or(def("TSTypeParameterInstantiation"), null),
|
|
@@ -80,6 +82,7 @@ module.exports = function (fork) {
|
|
|
80
82
|
"TSStringKeyword",
|
|
81
83
|
"TSSymbolKeyword",
|
|
82
84
|
"TSUndefinedKeyword",
|
|
85
|
+
"TSUnknownKeyword",
|
|
83
86
|
"TSVoidKeyword",
|
|
84
87
|
"TSThisType",
|
|
85
88
|
].forEach(keywordType => {
|
|
@@ -121,7 +124,7 @@ module.exports = function (fork) {
|
|
|
121
124
|
def("TSInferType")
|
|
122
125
|
.bases("TSType")
|
|
123
126
|
.build("typeParameter")
|
|
124
|
-
.field("typeParameter", def("
|
|
127
|
+
.field("typeParameter", def("TSTypeParameter"));
|
|
125
128
|
|
|
126
129
|
def("TSParenthesizedType")
|
|
127
130
|
.bases("TSType")
|
|
@@ -200,9 +203,9 @@ module.exports = function (fork) {
|
|
|
200
203
|
def("TSMappedType")
|
|
201
204
|
.bases("TSType")
|
|
202
205
|
.build("typeParameter", "typeAnnotation")
|
|
203
|
-
.field("readonly", Boolean, defaults["false"])
|
|
206
|
+
.field("readonly", or(Boolean, "+", "-"), defaults["false"])
|
|
204
207
|
.field("typeParameter", def("TSTypeParameter"))
|
|
205
|
-
.field("optional", Boolean, defaults["false"])
|
|
208
|
+
.field("optional", or(Boolean, "+", "-"), defaults["false"])
|
|
206
209
|
.field("typeAnnotation",
|
|
207
210
|
or(def("TSType"), null),
|
|
208
211
|
defaults["null"]);
|
|
@@ -212,6 +215,16 @@ module.exports = function (fork) {
|
|
|
212
215
|
.build("elementTypes")
|
|
213
216
|
.field("elementTypes", [def("TSType")]);
|
|
214
217
|
|
|
218
|
+
def("TSRestType")
|
|
219
|
+
.bases("TSType")
|
|
220
|
+
.build("typeAnnotation")
|
|
221
|
+
.field("typeAnnotation", def("TSType"));
|
|
222
|
+
|
|
223
|
+
def("TSOptionalType")
|
|
224
|
+
.bases("TSType")
|
|
225
|
+
.build("typeAnnotation")
|
|
226
|
+
.field("typeAnnotation", def("TSType"));
|
|
227
|
+
|
|
215
228
|
def("TSIndexedAccessType")
|
|
216
229
|
.bases("TSType")
|
|
217
230
|
.build("objectType", "indexType")
|
|
@@ -288,7 +301,7 @@ module.exports = function (fork) {
|
|
|
288
301
|
def("TSTypeQuery")
|
|
289
302
|
.bases("TSType")
|
|
290
303
|
.build("exprName")
|
|
291
|
-
.field("exprName",
|
|
304
|
+
.field("exprName", IdOrQualifiedName);
|
|
292
305
|
|
|
293
306
|
// Inferred from Babylon's tsParseTypeMember method.
|
|
294
307
|
var TSTypeMember = or(
|
|
@@ -306,6 +319,7 @@ module.exports = function (fork) {
|
|
|
306
319
|
|
|
307
320
|
def("TSTypeParameter")
|
|
308
321
|
.bases("Identifier")
|
|
322
|
+
.build("name", "constraint", "default")
|
|
309
323
|
.field("name", String)
|
|
310
324
|
.field("constraint", or(def("TSType"), null), defaults["null"])
|
|
311
325
|
.field("default", or(def("TSType"), null), defaults["null"]);
|
|
@@ -411,15 +425,6 @@ module.exports = function (fork) {
|
|
|
411
425
|
defaults["null"])
|
|
412
426
|
.field("body", def("TSInterfaceBody"));
|
|
413
427
|
|
|
414
|
-
["ClassDeclaration",
|
|
415
|
-
"ClassExpression",
|
|
416
|
-
].forEach(typeName => {
|
|
417
|
-
def(typeName)
|
|
418
|
-
.field("implements",
|
|
419
|
-
[def("TSExpressionWithTypeArguments")],
|
|
420
|
-
defaults.emptyArray);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
428
|
def("TSParameterProperty")
|
|
424
429
|
.bases("Pattern")
|
|
425
430
|
.build("parameter")
|
package/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Ben Newman <bn@cs.stanford.edu>",
|
|
3
3
|
"name": "ast-types",
|
|
4
|
+
"version": "0.11.7",
|
|
4
5
|
"description": "Esprima-compatible implementation of the Mozilla JS Parser API",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"ast",
|
|
@@ -18,7 +19,6 @@
|
|
|
18
19
|
"transformation",
|
|
19
20
|
"syntax"
|
|
20
21
|
],
|
|
21
|
-
"version": "0.11.3",
|
|
22
22
|
"homepage": "http://github.com/benjamn/ast-types",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"babel-types": "^6.26.0",
|
|
35
35
|
"babylon": "^7.0.0-beta.40",
|
|
36
|
-
"espree": "^
|
|
36
|
+
"espree": "^4.0.0",
|
|
37
37
|
"esprima": "~4.0.0",
|
|
38
38
|
"esprima-fb": "~14001.1.0-dev-harmony-fb",
|
|
39
|
-
"flow-parser": "^0.
|
|
39
|
+
"flow-parser": "^0.83.0",
|
|
40
40
|
"glob": "^7.1.2",
|
|
41
41
|
"mocha": "^5.0.0",
|
|
42
|
-
"reify": "^0.
|
|
42
|
+
"reify": "^0.18.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
45
|
+
"node": ">=4"
|
|
46
46
|
}
|
|
47
47
|
}
|