ast-types 0.9.13 → 0.10.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.
- package/.travis.yml +1 -0
- package/def/{babel6-core.js → babel-core.js} +127 -4
- package/def/babel.js +3 -106
- package/def/flow.js +354 -347
- package/def/jsx.js +22 -0
- package/lib/scope.js +4 -0
- package/main.js +13 -14
- package/package.json +4 -4
- package/def/babel6.js +0 -4
package/.travis.yml
CHANGED
|
@@ -1,13 +1,110 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
|
-
fork.use(require("./
|
|
2
|
+
fork.use(require("./es7"));
|
|
3
3
|
|
|
4
|
-
// var types = fork.types;
|
|
5
4
|
var types = fork.use(require("../lib/types"));
|
|
6
|
-
// var defaults = fork.shared.defaults;
|
|
7
5
|
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
8
6
|
var def = types.Type.def;
|
|
9
7
|
var or = types.Type.or;
|
|
10
8
|
|
|
9
|
+
def("Noop")
|
|
10
|
+
.bases("Statement")
|
|
11
|
+
.build();
|
|
12
|
+
|
|
13
|
+
def("DoExpression")
|
|
14
|
+
.bases("Expression")
|
|
15
|
+
.build("body")
|
|
16
|
+
.field("body", [def("Statement")]);
|
|
17
|
+
|
|
18
|
+
def("Super")
|
|
19
|
+
.bases("Expression")
|
|
20
|
+
.build();
|
|
21
|
+
|
|
22
|
+
def("BindExpression")
|
|
23
|
+
.bases("Expression")
|
|
24
|
+
.build("object", "callee")
|
|
25
|
+
.field("object", or(def("Expression"), null))
|
|
26
|
+
.field("callee", def("Expression"));
|
|
27
|
+
|
|
28
|
+
def("Decorator")
|
|
29
|
+
.bases("Node")
|
|
30
|
+
.build("expression")
|
|
31
|
+
.field("expression", def("Expression"));
|
|
32
|
+
|
|
33
|
+
def("Property")
|
|
34
|
+
.field("decorators",
|
|
35
|
+
or([def("Decorator")], null),
|
|
36
|
+
defaults["null"]);
|
|
37
|
+
|
|
38
|
+
def("MethodDefinition")
|
|
39
|
+
.field("decorators",
|
|
40
|
+
or([def("Decorator")], null),
|
|
41
|
+
defaults["null"]);
|
|
42
|
+
|
|
43
|
+
def("MetaProperty")
|
|
44
|
+
.bases("Expression")
|
|
45
|
+
.build("meta", "property")
|
|
46
|
+
.field("meta", def("Identifier"))
|
|
47
|
+
.field("property", def("Identifier"));
|
|
48
|
+
|
|
49
|
+
def("ParenthesizedExpression")
|
|
50
|
+
.bases("Expression")
|
|
51
|
+
.build("expression")
|
|
52
|
+
.field("expression", def("Expression"));
|
|
53
|
+
|
|
54
|
+
def("ImportSpecifier")
|
|
55
|
+
.bases("ModuleSpecifier")
|
|
56
|
+
.build("imported", "local")
|
|
57
|
+
.field("imported", def("Identifier"));
|
|
58
|
+
|
|
59
|
+
def("ImportDefaultSpecifier")
|
|
60
|
+
.bases("ModuleSpecifier")
|
|
61
|
+
.build("local");
|
|
62
|
+
|
|
63
|
+
def("ImportNamespaceSpecifier")
|
|
64
|
+
.bases("ModuleSpecifier")
|
|
65
|
+
.build("local");
|
|
66
|
+
|
|
67
|
+
def("ExportDefaultDeclaration")
|
|
68
|
+
.bases("Declaration")
|
|
69
|
+
.build("declaration")
|
|
70
|
+
.field("declaration", or(def("Declaration"), def("Expression")));
|
|
71
|
+
|
|
72
|
+
def("ExportNamedDeclaration")
|
|
73
|
+
.bases("Declaration")
|
|
74
|
+
.build("declaration", "specifiers", "source")
|
|
75
|
+
.field("declaration", or(def("Declaration"), null))
|
|
76
|
+
.field("specifiers", [def("ExportSpecifier")], defaults.emptyArray)
|
|
77
|
+
.field("source", or(def("Literal"), null), defaults["null"]);
|
|
78
|
+
|
|
79
|
+
def("ExportSpecifier")
|
|
80
|
+
.bases("ModuleSpecifier")
|
|
81
|
+
.build("local", "exported")
|
|
82
|
+
.field("exported", def("Identifier"));
|
|
83
|
+
|
|
84
|
+
def("ExportNamespaceSpecifier")
|
|
85
|
+
.bases("Specifier")
|
|
86
|
+
.build("exported")
|
|
87
|
+
.field("exported", def("Identifier"));
|
|
88
|
+
|
|
89
|
+
def("ExportDefaultSpecifier")
|
|
90
|
+
.bases("Specifier")
|
|
91
|
+
.build("exported")
|
|
92
|
+
.field("exported", def("Identifier"));
|
|
93
|
+
|
|
94
|
+
def("ExportAllDeclaration")
|
|
95
|
+
.bases("Declaration")
|
|
96
|
+
.build("exported", "source")
|
|
97
|
+
.field("exported", or(def("Identifier"), null))
|
|
98
|
+
.field("source", def("Literal"));
|
|
99
|
+
|
|
100
|
+
def("CommentBlock")
|
|
101
|
+
.bases("Comment")
|
|
102
|
+
.build("value", /*optional:*/ "leading", "trailing");
|
|
103
|
+
|
|
104
|
+
def("CommentLine")
|
|
105
|
+
.bases("Comment")
|
|
106
|
+
.build("value", /*optional:*/ "leading", "trailing");
|
|
107
|
+
|
|
11
108
|
def("Directive")
|
|
12
109
|
.bases("Node")
|
|
13
110
|
.build("value")
|
|
@@ -39,7 +136,33 @@ module.exports = function (fork) {
|
|
|
39
136
|
def("NumericLiteral")
|
|
40
137
|
.bases("Literal")
|
|
41
138
|
.build("value")
|
|
42
|
-
.field("value", Number)
|
|
139
|
+
.field("value", Number)
|
|
140
|
+
.field("raw", or(String, null), defaults["null"])
|
|
141
|
+
.field("extra", {
|
|
142
|
+
rawValue: Number,
|
|
143
|
+
raw: String
|
|
144
|
+
}, function getDefault() {
|
|
145
|
+
return {
|
|
146
|
+
rawValue: this.value,
|
|
147
|
+
raw: this.value + ""
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
def("BigIntLiteral")
|
|
152
|
+
.bases("Literal")
|
|
153
|
+
.build("value")
|
|
154
|
+
// Only String really seems appropriate here, since BigInt values
|
|
155
|
+
// often exceed the limits of JS numbers.
|
|
156
|
+
.field("value", or(String, Number))
|
|
157
|
+
.field("extra", {
|
|
158
|
+
rawValue: String,
|
|
159
|
+
raw: String
|
|
160
|
+
}, function getDefault() {
|
|
161
|
+
return {
|
|
162
|
+
rawValue: String(this.value),
|
|
163
|
+
raw: this.value + "n"
|
|
164
|
+
};
|
|
165
|
+
});
|
|
43
166
|
|
|
44
167
|
def("NullLiteral")
|
|
45
168
|
.bases("Literal")
|
package/def/babel.js
CHANGED
|
@@ -1,107 +1,4 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
6
|
-
var def = types.Type.def;
|
|
7
|
-
var or = types.Type.or;
|
|
8
|
-
|
|
9
|
-
def("Noop")
|
|
10
|
-
.bases("Node")
|
|
11
|
-
.build();
|
|
12
|
-
|
|
13
|
-
def("DoExpression")
|
|
14
|
-
.bases("Expression")
|
|
15
|
-
.build("body")
|
|
16
|
-
.field("body", [def("Statement")]);
|
|
17
|
-
|
|
18
|
-
def("Super")
|
|
19
|
-
.bases("Expression")
|
|
20
|
-
.build();
|
|
21
|
-
|
|
22
|
-
def("BindExpression")
|
|
23
|
-
.bases("Expression")
|
|
24
|
-
.build("object", "callee")
|
|
25
|
-
.field("object", or(def("Expression"), null))
|
|
26
|
-
.field("callee", def("Expression"));
|
|
27
|
-
|
|
28
|
-
def("Decorator")
|
|
29
|
-
.bases("Node")
|
|
30
|
-
.build("expression")
|
|
31
|
-
.field("expression", def("Expression"));
|
|
32
|
-
|
|
33
|
-
def("Property")
|
|
34
|
-
.field("decorators",
|
|
35
|
-
or([def("Decorator")], null),
|
|
36
|
-
defaults["null"]);
|
|
37
|
-
|
|
38
|
-
def("MethodDefinition")
|
|
39
|
-
.field("decorators",
|
|
40
|
-
or([def("Decorator")], null),
|
|
41
|
-
defaults["null"]);
|
|
42
|
-
|
|
43
|
-
def("MetaProperty")
|
|
44
|
-
.bases("Expression")
|
|
45
|
-
.build("meta", "property")
|
|
46
|
-
.field("meta", def("Identifier"))
|
|
47
|
-
.field("property", def("Identifier"));
|
|
48
|
-
|
|
49
|
-
def("ParenthesizedExpression")
|
|
50
|
-
.bases("Expression")
|
|
51
|
-
.build("expression")
|
|
52
|
-
.field("expression", def("Expression"));
|
|
53
|
-
|
|
54
|
-
def("ImportSpecifier")
|
|
55
|
-
.bases("ModuleSpecifier")
|
|
56
|
-
.build("imported", "local")
|
|
57
|
-
.field("imported", def("Identifier"));
|
|
58
|
-
|
|
59
|
-
def("ImportDefaultSpecifier")
|
|
60
|
-
.bases("ModuleSpecifier")
|
|
61
|
-
.build("local");
|
|
62
|
-
|
|
63
|
-
def("ImportNamespaceSpecifier")
|
|
64
|
-
.bases("ModuleSpecifier")
|
|
65
|
-
.build("local");
|
|
66
|
-
|
|
67
|
-
def("ExportDefaultDeclaration")
|
|
68
|
-
.bases("Declaration")
|
|
69
|
-
.build("declaration")
|
|
70
|
-
.field("declaration", or(def("Declaration"), def("Expression")));
|
|
71
|
-
|
|
72
|
-
def("ExportNamedDeclaration")
|
|
73
|
-
.bases("Declaration")
|
|
74
|
-
.build("declaration", "specifiers", "source")
|
|
75
|
-
.field("declaration", or(def("Declaration"), null))
|
|
76
|
-
.field("specifiers", [def("ExportSpecifier")], defaults.emptyArray)
|
|
77
|
-
.field("source", or(def("Literal"), null), defaults["null"]);
|
|
78
|
-
|
|
79
|
-
def("ExportSpecifier")
|
|
80
|
-
.bases("ModuleSpecifier")
|
|
81
|
-
.build("local", "exported")
|
|
82
|
-
.field("exported", def("Identifier"));
|
|
83
|
-
|
|
84
|
-
def("ExportNamespaceSpecifier")
|
|
85
|
-
.bases("Specifier")
|
|
86
|
-
.build("exported")
|
|
87
|
-
.field("exported", def("Identifier"));
|
|
88
|
-
|
|
89
|
-
def("ExportDefaultSpecifier")
|
|
90
|
-
.bases("Specifier")
|
|
91
|
-
.build("exported")
|
|
92
|
-
.field("exported", def("Identifier"));
|
|
93
|
-
|
|
94
|
-
def("ExportAllDeclaration")
|
|
95
|
-
.bases("Declaration")
|
|
96
|
-
.build("exported", "source")
|
|
97
|
-
.field("exported", or(def("Identifier"), null))
|
|
98
|
-
.field("source", def("Literal"));
|
|
99
|
-
|
|
100
|
-
def("CommentBlock")
|
|
101
|
-
.bases("Comment")
|
|
102
|
-
.build("value", /*optional:*/ "leading", "trailing");
|
|
103
|
-
|
|
104
|
-
def("CommentLine")
|
|
105
|
-
.bases("Comment")
|
|
106
|
-
.build("value", /*optional:*/ "leading", "trailing");
|
|
107
|
-
};
|
|
2
|
+
fork.use(require("./babel-core"));
|
|
3
|
+
fork.use(require("./flow"));
|
|
4
|
+
};
|
package/def/flow.js
CHANGED
|
@@ -1,349 +1,356 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def("
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def("
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def("
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def("
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
def("
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def("
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def("
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
def("
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
def("
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
def("
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
2
|
+
fork.use(require("./es7"));
|
|
3
|
+
|
|
4
|
+
var types = fork.use(require("../lib/types"));
|
|
5
|
+
var def = types.Type.def;
|
|
6
|
+
var or = types.Type.or;
|
|
7
|
+
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
8
|
+
|
|
9
|
+
// Type Annotations
|
|
10
|
+
def("Type").bases("Node");
|
|
11
|
+
|
|
12
|
+
def("AnyTypeAnnotation")
|
|
13
|
+
.bases("Type")
|
|
14
|
+
.build();
|
|
15
|
+
|
|
16
|
+
def("EmptyTypeAnnotation")
|
|
17
|
+
.bases("Type")
|
|
18
|
+
.build();
|
|
19
|
+
|
|
20
|
+
def("MixedTypeAnnotation")
|
|
21
|
+
.bases("Type")
|
|
22
|
+
.build();
|
|
23
|
+
|
|
24
|
+
def("VoidTypeAnnotation")
|
|
25
|
+
.bases("Type")
|
|
26
|
+
.build();
|
|
27
|
+
|
|
28
|
+
def("NumberTypeAnnotation")
|
|
29
|
+
.bases("Type")
|
|
30
|
+
.build();
|
|
31
|
+
|
|
32
|
+
def("NumberLiteralTypeAnnotation")
|
|
33
|
+
.bases("Type")
|
|
34
|
+
.build("value", "raw")
|
|
35
|
+
.field("value", Number)
|
|
36
|
+
.field("raw", String);
|
|
37
|
+
|
|
38
|
+
// Babylon 6 differs in AST from Flow
|
|
39
|
+
// same as NumberLiteralTypeAnnotation
|
|
40
|
+
def("NumericLiteralTypeAnnotation")
|
|
41
|
+
.bases("Type")
|
|
42
|
+
.build("value", "raw")
|
|
43
|
+
.field("value", Number)
|
|
44
|
+
.field("raw", String);
|
|
45
|
+
|
|
46
|
+
def("StringTypeAnnotation")
|
|
47
|
+
.bases("Type")
|
|
48
|
+
.build();
|
|
49
|
+
|
|
50
|
+
def("StringLiteralTypeAnnotation")
|
|
51
|
+
.bases("Type")
|
|
52
|
+
.build("value", "raw")
|
|
53
|
+
.field("value", String)
|
|
54
|
+
.field("raw", String);
|
|
55
|
+
|
|
56
|
+
def("BooleanTypeAnnotation")
|
|
57
|
+
.bases("Type")
|
|
58
|
+
.build();
|
|
59
|
+
|
|
60
|
+
def("BooleanLiteralTypeAnnotation")
|
|
61
|
+
.bases("Type")
|
|
62
|
+
.build("value", "raw")
|
|
63
|
+
.field("value", Boolean)
|
|
64
|
+
.field("raw", String);
|
|
65
|
+
|
|
66
|
+
def("TypeAnnotation")
|
|
67
|
+
.bases("Node")
|
|
68
|
+
.build("typeAnnotation")
|
|
69
|
+
.field("typeAnnotation", def("Type"));
|
|
70
|
+
|
|
71
|
+
def("NullableTypeAnnotation")
|
|
72
|
+
.bases("Type")
|
|
73
|
+
.build("typeAnnotation")
|
|
74
|
+
.field("typeAnnotation", def("Type"));
|
|
75
|
+
|
|
76
|
+
def("NullLiteralTypeAnnotation")
|
|
77
|
+
.bases("Type")
|
|
78
|
+
.build();
|
|
79
|
+
|
|
80
|
+
def("NullTypeAnnotation")
|
|
81
|
+
.bases("Type")
|
|
82
|
+
.build();
|
|
83
|
+
|
|
84
|
+
def("ThisTypeAnnotation")
|
|
85
|
+
.bases("Type")
|
|
86
|
+
.build();
|
|
87
|
+
|
|
88
|
+
def("ExistsTypeAnnotation")
|
|
89
|
+
.bases("Type")
|
|
90
|
+
.build();
|
|
91
|
+
|
|
92
|
+
def("ExistentialTypeParam")
|
|
93
|
+
.bases("Type")
|
|
94
|
+
.build();
|
|
95
|
+
|
|
96
|
+
def("FunctionTypeAnnotation")
|
|
97
|
+
.bases("Type")
|
|
98
|
+
.build("params", "returnType", "rest", "typeParameters")
|
|
99
|
+
.field("params", [def("FunctionTypeParam")])
|
|
100
|
+
.field("returnType", def("Type"))
|
|
101
|
+
.field("rest", or(def("FunctionTypeParam"), null))
|
|
102
|
+
.field("typeParameters", or(def("TypeParameterDeclaration"), null));
|
|
103
|
+
|
|
104
|
+
def("FunctionTypeParam")
|
|
105
|
+
.bases("Node")
|
|
106
|
+
.build("name", "typeAnnotation", "optional")
|
|
107
|
+
.field("name", def("Identifier"))
|
|
108
|
+
.field("typeAnnotation", def("Type"))
|
|
109
|
+
.field("optional", Boolean);
|
|
110
|
+
|
|
111
|
+
def("ArrayTypeAnnotation")
|
|
112
|
+
.bases("Type")
|
|
113
|
+
.build("elementType")
|
|
114
|
+
.field("elementType", def("Type"));
|
|
115
|
+
|
|
116
|
+
def("ObjectTypeAnnotation")
|
|
117
|
+
.bases("Type")
|
|
118
|
+
.build("properties", "indexers", "callProperties")
|
|
119
|
+
.field("properties", [
|
|
120
|
+
or(def("ObjectTypeProperty"),
|
|
121
|
+
def("ObjectTypeSpreadProperty"))
|
|
122
|
+
])
|
|
123
|
+
.field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray)
|
|
124
|
+
.field("callProperties",
|
|
125
|
+
[def("ObjectTypeCallProperty")],
|
|
126
|
+
defaults.emptyArray)
|
|
127
|
+
.field("exact", Boolean, defaults["false"]);
|
|
128
|
+
|
|
129
|
+
def("Variance")
|
|
130
|
+
.bases("Node")
|
|
131
|
+
.build("kind")
|
|
132
|
+
.field("kind", or("plus", "minus"));
|
|
133
|
+
|
|
134
|
+
var LegacyVariance = or(
|
|
135
|
+
def("Variance"),
|
|
136
|
+
"plus",
|
|
137
|
+
"minus",
|
|
138
|
+
null
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
def("ObjectTypeProperty")
|
|
142
|
+
.bases("Node")
|
|
143
|
+
.build("key", "value", "optional")
|
|
144
|
+
.field("key", or(def("Literal"), def("Identifier")))
|
|
145
|
+
.field("value", def("Type"))
|
|
146
|
+
.field("optional", Boolean)
|
|
147
|
+
.field("variance", LegacyVariance, defaults["null"]);
|
|
148
|
+
|
|
149
|
+
def("ObjectTypeIndexer")
|
|
150
|
+
.bases("Node")
|
|
151
|
+
.build("id", "key", "value")
|
|
152
|
+
.field("id", def("Identifier"))
|
|
153
|
+
.field("key", def("Type"))
|
|
154
|
+
.field("value", def("Type"))
|
|
155
|
+
.field("variance", LegacyVariance, defaults["null"]);
|
|
156
|
+
|
|
157
|
+
def("ObjectTypeCallProperty")
|
|
158
|
+
.bases("Node")
|
|
159
|
+
.build("value")
|
|
160
|
+
.field("value", def("FunctionTypeAnnotation"))
|
|
161
|
+
.field("static", Boolean, defaults["false"]);
|
|
162
|
+
|
|
163
|
+
def("QualifiedTypeIdentifier")
|
|
164
|
+
.bases("Node")
|
|
165
|
+
.build("qualification", "id")
|
|
166
|
+
.field("qualification",
|
|
167
|
+
or(def("Identifier"),
|
|
168
|
+
def("QualifiedTypeIdentifier")))
|
|
169
|
+
.field("id", def("Identifier"));
|
|
170
|
+
|
|
171
|
+
def("GenericTypeAnnotation")
|
|
172
|
+
.bases("Type")
|
|
173
|
+
.build("id", "typeParameters")
|
|
174
|
+
.field("id", or(def("Identifier"), def("QualifiedTypeIdentifier")))
|
|
175
|
+
.field("typeParameters", or(def("TypeParameterInstantiation"), null));
|
|
176
|
+
|
|
177
|
+
def("MemberTypeAnnotation")
|
|
178
|
+
.bases("Type")
|
|
179
|
+
.build("object", "property")
|
|
180
|
+
.field("object", def("Identifier"))
|
|
181
|
+
.field("property",
|
|
182
|
+
or(def("MemberTypeAnnotation"),
|
|
183
|
+
def("GenericTypeAnnotation")));
|
|
184
|
+
|
|
185
|
+
def("UnionTypeAnnotation")
|
|
186
|
+
.bases("Type")
|
|
187
|
+
.build("types")
|
|
188
|
+
.field("types", [def("Type")]);
|
|
189
|
+
|
|
190
|
+
def("IntersectionTypeAnnotation")
|
|
191
|
+
.bases("Type")
|
|
192
|
+
.build("types")
|
|
193
|
+
.field("types", [def("Type")]);
|
|
194
|
+
|
|
195
|
+
def("TypeofTypeAnnotation")
|
|
196
|
+
.bases("Type")
|
|
197
|
+
.build("argument")
|
|
198
|
+
.field("argument", def("Type"));
|
|
199
|
+
|
|
200
|
+
def("ObjectTypeSpreadProperty")
|
|
201
|
+
.bases("Node")
|
|
202
|
+
.build("argument")
|
|
203
|
+
.field("argument", def("Type"));
|
|
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"]);
|
|
210
|
+
|
|
211
|
+
def("TypeParameterDeclaration")
|
|
212
|
+
.bases("Node")
|
|
213
|
+
.build("params")
|
|
214
|
+
.field("params", [def("TypeParameter")]);
|
|
215
|
+
|
|
216
|
+
def("TypeParameterInstantiation")
|
|
217
|
+
.bases("Node")
|
|
218
|
+
.build("params")
|
|
219
|
+
.field("params", [def("Type")]);
|
|
220
|
+
|
|
221
|
+
def("TypeParameter")
|
|
222
|
+
.bases("Type")
|
|
223
|
+
.build("name", "variance", "bound")
|
|
224
|
+
.field("name", String)
|
|
225
|
+
.field("variance", LegacyVariance, defaults["null"])
|
|
226
|
+
.field("bound",
|
|
227
|
+
or(def("TypeAnnotation"), null),
|
|
228
|
+
defaults["null"]);
|
|
229
|
+
|
|
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
|
+
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
|
+
.field("variance", LegacyVariance, defaults["null"]);
|
|
244
|
+
|
|
245
|
+
def("ClassImplements")
|
|
246
|
+
.field("typeParameters",
|
|
247
|
+
or(def("TypeParameterInstantiation"), null),
|
|
248
|
+
defaults["null"]);
|
|
249
|
+
|
|
250
|
+
def("InterfaceDeclaration")
|
|
251
|
+
.bases("Declaration")
|
|
252
|
+
.build("id", "body", "extends")
|
|
253
|
+
.field("id", def("Identifier"))
|
|
254
|
+
.field("typeParameters",
|
|
255
|
+
or(def("TypeParameterDeclaration"), null),
|
|
256
|
+
defaults["null"])
|
|
257
|
+
.field("body", def("ObjectTypeAnnotation"))
|
|
258
|
+
.field("extends", [def("InterfaceExtends")]);
|
|
259
|
+
|
|
260
|
+
def("DeclareInterface")
|
|
261
|
+
.bases("InterfaceDeclaration")
|
|
262
|
+
.build("id", "body", "extends");
|
|
263
|
+
|
|
264
|
+
def("InterfaceExtends")
|
|
265
|
+
.bases("Node")
|
|
266
|
+
.build("id")
|
|
267
|
+
.field("id", def("Identifier"))
|
|
268
|
+
.field("typeParameters", or(def("TypeParameterInstantiation"), null));
|
|
269
|
+
|
|
270
|
+
def("TypeAlias")
|
|
271
|
+
.bases("Declaration")
|
|
272
|
+
.build("id", "typeParameters", "right")
|
|
273
|
+
.field("id", def("Identifier"))
|
|
274
|
+
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
275
|
+
.field("right", def("Type"));
|
|
276
|
+
|
|
277
|
+
def("OpaqueType")
|
|
278
|
+
.bases("Declaration")
|
|
279
|
+
.build("id", "typeParameters", "impltype", "supertype")
|
|
280
|
+
.field("id", def("Identifier"))
|
|
281
|
+
.field("typeParameters", or(def("TypeParameterDeclaration"), null))
|
|
282
|
+
.field("implType", def("Type"))
|
|
283
|
+
.field("superType", def("Type"));
|
|
284
|
+
|
|
285
|
+
def("DeclareTypeAlias")
|
|
286
|
+
.bases("TypeAlias")
|
|
287
|
+
.build("id", "typeParameters", "right");
|
|
288
|
+
|
|
289
|
+
def("DeclareOpaqueType")
|
|
290
|
+
.bases("TypeAlias")
|
|
291
|
+
.build("id", "typeParameters", "supertype");
|
|
292
|
+
|
|
293
|
+
def("TypeCastExpression")
|
|
294
|
+
.bases("Expression")
|
|
295
|
+
.build("expression", "typeAnnotation")
|
|
296
|
+
.field("expression", def("Expression"))
|
|
297
|
+
.field("typeAnnotation", def("TypeAnnotation"));
|
|
298
|
+
|
|
299
|
+
def("TupleTypeAnnotation")
|
|
300
|
+
.bases("Type")
|
|
301
|
+
.build("types")
|
|
302
|
+
.field("types", [def("Type")]);
|
|
303
|
+
|
|
304
|
+
def("DeclareVariable")
|
|
305
|
+
.bases("Statement")
|
|
306
|
+
.build("id")
|
|
307
|
+
.field("id", def("Identifier"));
|
|
308
|
+
|
|
309
|
+
def("DeclareFunction")
|
|
310
|
+
.bases("Statement")
|
|
311
|
+
.build("id")
|
|
312
|
+
.field("id", def("Identifier"));
|
|
313
|
+
|
|
314
|
+
def("DeclareClass")
|
|
315
|
+
.bases("InterfaceDeclaration")
|
|
316
|
+
.build("id");
|
|
317
|
+
|
|
318
|
+
def("DeclareModule")
|
|
319
|
+
.bases("Statement")
|
|
320
|
+
.build("id", "body")
|
|
321
|
+
.field("id", or(def("Identifier"), def("Literal")))
|
|
322
|
+
.field("body", def("BlockStatement"));
|
|
323
|
+
|
|
324
|
+
def("DeclareModuleExports")
|
|
325
|
+
.bases("Statement")
|
|
326
|
+
.build("typeAnnotation")
|
|
327
|
+
.field("typeAnnotation", def("Type"));
|
|
328
|
+
|
|
329
|
+
def("DeclareExportDeclaration")
|
|
330
|
+
.bases("Declaration")
|
|
331
|
+
.build("default", "declaration", "specifiers", "source")
|
|
332
|
+
.field("default", Boolean)
|
|
333
|
+
.field("declaration", or(
|
|
334
|
+
def("DeclareVariable"),
|
|
335
|
+
def("DeclareFunction"),
|
|
336
|
+
def("DeclareClass"),
|
|
337
|
+
def("Type"), // Implies default.
|
|
338
|
+
null
|
|
339
|
+
))
|
|
340
|
+
.field("specifiers", [or(
|
|
341
|
+
def("ExportSpecifier"),
|
|
342
|
+
def("ExportBatchSpecifier")
|
|
343
|
+
)], defaults.emptyArray)
|
|
344
|
+
.field("source", or(
|
|
345
|
+
def("Literal"),
|
|
346
|
+
null
|
|
347
|
+
), defaults["null"]);
|
|
348
|
+
|
|
349
|
+
def("DeclareExportAllDeclaration")
|
|
350
|
+
.bases("Declaration")
|
|
351
|
+
.build("source")
|
|
352
|
+
.field("source", or(
|
|
353
|
+
def("Literal"),
|
|
354
|
+
null
|
|
355
|
+
), defaults["null"]);
|
|
349
356
|
};
|
package/def/jsx.js
CHANGED
|
@@ -63,6 +63,7 @@ module.exports = function (fork) {
|
|
|
63
63
|
.field("children", [or(
|
|
64
64
|
def("JSXElement"),
|
|
65
65
|
def("JSXExpressionContainer"),
|
|
66
|
+
def("JSXFragment"),
|
|
66
67
|
def("JSXText"),
|
|
67
68
|
def("Literal") // TODO Esprima should return JSXText instead.
|
|
68
69
|
)], defaults.emptyArray)
|
|
@@ -93,6 +94,27 @@ module.exports = function (fork) {
|
|
|
93
94
|
.build("name")
|
|
94
95
|
.field("name", JSXElementName);
|
|
95
96
|
|
|
97
|
+
def("JSXFragment")
|
|
98
|
+
.bases("Expression")
|
|
99
|
+
.build("openingElement", "closingElement", "children")
|
|
100
|
+
.field("openingElement", def("JSXOpeningFragment"))
|
|
101
|
+
.field("closingElement", def("JSXClosingFragment"))
|
|
102
|
+
.field("children", [or(
|
|
103
|
+
def("JSXElement"),
|
|
104
|
+
def("JSXExpressionContainer"),
|
|
105
|
+
def("JSXFragment"),
|
|
106
|
+
def("JSXText"),
|
|
107
|
+
def("Literal") // TODO Esprima should return JSXText instead.
|
|
108
|
+
)], defaults.emptyArray)
|
|
109
|
+
|
|
110
|
+
def("JSXOpeningFragment")
|
|
111
|
+
.bases("Node") // TODO Same concern.
|
|
112
|
+
.build();
|
|
113
|
+
|
|
114
|
+
def("JSXClosingFragment")
|
|
115
|
+
.bases("Node") // TODO Same concern.
|
|
116
|
+
.build();
|
|
117
|
+
|
|
96
118
|
def("JSXText")
|
|
97
119
|
.bases("Literal")
|
|
98
120
|
.build("value")
|
package/lib/scope.js
CHANGED
|
@@ -274,6 +274,10 @@ module.exports = function (fork) {
|
|
|
274
274
|
bindings[pattern.name] = [patternPath];
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
} else if (namedTypes.AssignmentPattern &&
|
|
278
|
+
namedTypes.AssignmentPattern.check(pattern)) {
|
|
279
|
+
addPattern(patternPath.get('left'), bindings);
|
|
280
|
+
|
|
277
281
|
} else if (namedTypes.ObjectPattern &&
|
|
278
282
|
namedTypes.ObjectPattern.check(pattern)) {
|
|
279
283
|
patternPath.get('properties').each(function(propertyPath) {
|
package/main.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
module.exports = require('./fork')([
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
// This core module of AST types captures ES5 as it is parsed today by
|
|
3
|
+
// git://github.com/ariya/esprima.git#master.
|
|
4
|
+
require("./def/core"),
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
require("./def/babel6")
|
|
6
|
+
// Feel free to add to or remove from this list of extension modules to
|
|
7
|
+
// configure the precise type hierarchy that you need.
|
|
8
|
+
require("./def/es6"),
|
|
9
|
+
require("./def/es7"),
|
|
10
|
+
require("./def/mozilla"),
|
|
11
|
+
require("./def/e4x"),
|
|
12
|
+
require("./def/jsx"),
|
|
13
|
+
require("./def/flow"),
|
|
14
|
+
require("./def/esprima"),
|
|
15
|
+
require("./def/babel")
|
|
17
16
|
]);
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"transformation",
|
|
19
19
|
"syntax"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.
|
|
21
|
+
"version": "0.10.2",
|
|
22
22
|
"homepage": "http://github.com/benjamn/ast-types",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"dependencies": {},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"babel-types": "^6.26.0",
|
|
35
|
-
"babylon": "^
|
|
35
|
+
"babylon": "^7.0.0-beta.31",
|
|
36
36
|
"espree": "^3.1.7",
|
|
37
37
|
"esprima": "~4.0.0",
|
|
38
38
|
"esprima-fb": "~14001.1.0-dev-harmony-fb",
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"reify": "^0.
|
|
39
|
+
"mocha": "^5.0.0",
|
|
40
|
+
"reify": "^0.14.1"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">= 0.8"
|
package/def/babel6.js
DELETED