@modern-js/module-tools 2.21.1 → 2.22.1

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/compiled/@rollup/plugin-json/@rollup/pluginutils/types/index.d.ts +8 -2
  3. package/compiled/@rollup/plugin-json/estree/index.d.ts +677 -548
  4. package/compiled/@rollup/plugin-json/index.js +1 -1
  5. package/compiled/@rollup/plugin-json/package.json +1 -1
  6. package/compiled/@rollup/plugin-json/rollup/dist/rollup.d.ts +167 -150
  7. package/compiled/@rollup/plugin-json/types/index.d.ts +2 -2
  8. package/compiled/rollup/249.index.js +103 -0
  9. package/compiled/rollup/index.js +36 -21
  10. package/compiled/rollup/package.json +1 -1
  11. package/compiled/rollup/types/rollup.d.ts +167 -150
  12. package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +3 -105
  13. package/compiled/rollup-plugin-dts/index.js +1 -1
  14. package/compiled/rollup-plugin-dts/package.json +1 -1
  15. package/compiled/rollup-plugin-dts/rollup/dist/rollup.d.ts +167 -150
  16. package/dist/build.js +3 -1
  17. package/dist/build.js.map +1 -1
  18. package/dist/builder/build.js +37 -14
  19. package/dist/builder/build.js.map +1 -1
  20. package/dist/builder/clear.js +6 -2
  21. package/dist/builder/clear.js.map +1 -1
  22. package/dist/builder/copy.js +9 -3
  23. package/dist/builder/copy.js.map +1 -1
  24. package/dist/builder/dts/index.js +6 -2
  25. package/dist/builder/dts/index.js.map +1 -1
  26. package/dist/builder/dts/rollup.js +3 -1
  27. package/dist/builder/dts/rollup.js.map +1 -1
  28. package/dist/builder/dts/tsc.js +6 -2
  29. package/dist/builder/dts/tsc.js.map +1 -1
  30. package/dist/builder/index.js +3 -1
  31. package/dist/builder/index.js.map +1 -1
  32. package/dist/builder/platform.js +3 -1
  33. package/dist/builder/platform.js.map +1 -1
  34. package/dist/cli.js +3 -1
  35. package/dist/cli.js.map +1 -1
  36. package/dist/command.js +12 -4
  37. package/dist/command.js.map +1 -1
  38. package/dist/config/defineConfig.js +6 -2
  39. package/dist/config/defineConfig.js.map +1 -1
  40. package/dist/config/legacySchema.js +21 -7
  41. package/dist/config/legacySchema.js.map +1 -1
  42. package/dist/config/normalize.js +18 -6
  43. package/dist/config/normalize.js.map +1 -1
  44. package/dist/config/schema.js +21 -7
  45. package/dist/config/schema.js.map +1 -1
  46. package/dist/config/transformLegacyConfig.js +30 -10
  47. package/dist/config/transformLegacyConfig.js.map +1 -1
  48. package/dist/constants/build.js +3 -1
  49. package/dist/constants/build.js.map +1 -1
  50. package/dist/constants/buildPresets.js +54 -18
  51. package/dist/constants/buildPresets.js.map +1 -1
  52. package/dist/constants/colors.js +9 -3
  53. package/dist/constants/colors.js.map +1 -1
  54. package/dist/constants/dts.js +12 -4
  55. package/dist/constants/dts.js.map +1 -1
  56. package/dist/constants/file.js +9 -3
  57. package/dist/constants/file.js.map +1 -1
  58. package/dist/constants/legacyBuildPresets.js +18 -6
  59. package/dist/constants/legacyBuildPresets.js.map +1 -1
  60. package/dist/constants/log.js +21 -7
  61. package/dist/constants/log.js.map +1 -1
  62. package/dist/dev.js +6 -2
  63. package/dist/dev.js.map +1 -1
  64. package/dist/error.js +18 -6
  65. package/dist/error.js.map +1 -1
  66. package/dist/hooks/build.js +6 -2
  67. package/dist/hooks/build.js.map +1 -1
  68. package/dist/hooks/dev.js +3 -1
  69. package/dist/hooks/dev.js.map +1 -1
  70. package/dist/hooks/index.js +3 -1
  71. package/dist/hooks/index.js.map +1 -1
  72. package/dist/hooks/misc.js +3 -1
  73. package/dist/hooks/misc.js.map +1 -1
  74. package/dist/index.js +12 -4
  75. package/dist/index.js.map +1 -1
  76. package/dist/locale/en.js +3 -1
  77. package/dist/locale/en.js.map +1 -1
  78. package/dist/locale/index.js +6 -2
  79. package/dist/locale/index.js.map +1 -1
  80. package/dist/locale/zh.js +3 -1
  81. package/dist/locale/zh.js.map +1 -1
  82. package/dist/plugins.js +3 -1
  83. package/dist/plugins.js.map +1 -1
  84. package/dist/types/config/index.d.ts +3 -0
  85. package/dist/types/config/index.js.map +1 -1
  86. package/dist/utils/builder.js +15 -5
  87. package/dist/utils/builder.js.map +1 -1
  88. package/dist/utils/common.js +3 -1
  89. package/dist/utils/common.js.map +1 -1
  90. package/dist/utils/config.js +15 -5
  91. package/dist/utils/config.js.map +1 -1
  92. package/dist/utils/context.js +3 -1
  93. package/dist/utils/context.js.map +1 -1
  94. package/dist/utils/dts.js +15 -5
  95. package/dist/utils/dts.js.map +1 -1
  96. package/dist/utils/input.js +15 -5
  97. package/dist/utils/input.js.map +1 -1
  98. package/dist/utils/language.js +3 -1
  99. package/dist/utils/language.js.map +1 -1
  100. package/dist/utils/libuildPlugins.js +6 -2
  101. package/dist/utils/libuildPlugins.js.map +1 -1
  102. package/dist/utils/log.js +3 -1
  103. package/dist/utils/log.js.map +1 -1
  104. package/dist/utils/onExit.js +3 -1
  105. package/dist/utils/onExit.js.map +1 -1
  106. package/dist/utils/path.js +3 -1
  107. package/dist/utils/path.js.map +1 -1
  108. package/dist/utils/print.js +21 -7
  109. package/dist/utils/print.js.map +1 -1
  110. package/dist/utils/style.js +12 -4
  111. package/dist/utils/style.js.map +1 -1
  112. package/dist/utils/tspathsTransform.js +3 -1
  113. package/dist/utils/tspathsTransform.js.map +1 -1
  114. package/package.json +16 -16
  115. package/compiled/@rollup/plugin-json/license +0 -21
@@ -1,548 +1,677 @@
1
- // Type definitions for ESTree AST specification
2
- // Project: https://github.com/estree/estree
3
- // Definitions by: RReverser <https://github.com/RReverser>
4
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
-
6
- // This definition file follows a somewhat unusual format. ESTree allows
7
- // runtime type checks based on the `type` parameter. In order to explain this
8
- // to typescript we want to use discriminated union types:
9
- // https://github.com/Microsoft/TypeScript/pull/9163
10
- //
11
- // For ESTree this is a bit tricky because the high level interfaces like
12
- // Node or Function are pulling double duty. We want to pass common fields down
13
- // to the interfaces that extend them (like Identifier or
14
- // ArrowFunctionExpression), but you can't extend a type union or enforce
15
- // common fields on them. So we've split the high level interfaces into two
16
- // types, a base type which passes down inhereted fields, and a type union of
17
- // all types which extend the base type. Only the type union is exported, and
18
- // the union is how other types refer to the collection of inheriting types.
19
- //
20
- // This makes the definitions file here somewhat more difficult to maintain,
21
- // but it has the notable advantage of making ESTree much easier to use as
22
- // an end user.
23
-
24
- interface BaseNodeWithoutComments {
25
- // Every leaf interface that extends BaseNode must specify a type property.
26
- // The type property should be a string literal. For example, Identifier
27
- // has: `type: "Identifier"`
28
- type: string;
29
- loc?: SourceLocation | null;
30
- range?: [number, number];
31
- }
32
-
33
- interface BaseNode extends BaseNodeWithoutComments {
34
- leadingComments?: Array<Comment>;
35
- trailingComments?: Array<Comment>;
36
- }
37
-
38
- export type Node =
39
- Identifier | Literal | Program | Function | SwitchCase | CatchClause |
40
- VariableDeclarator | Statement | Expression | Property |
41
- AssignmentProperty | Super | TemplateElement | SpreadElement | Pattern |
42
- ClassBody | Class | MethodDefinition | ModuleDeclaration | ModuleSpecifier;
43
-
44
- export interface Comment extends BaseNodeWithoutComments {
45
- type: "Line" | "Block";
46
- value: string;
47
- }
48
-
49
- interface SourceLocation {
50
- source?: string | null;
51
- start: Position;
52
- end: Position;
53
- }
54
-
55
- export interface Position {
56
- /** >= 1 */
57
- line: number;
58
- /** >= 0 */
59
- column: number;
60
- }
61
-
62
- export interface Program extends BaseNode {
63
- type: "Program";
64
- sourceType: "script" | "module";
65
- body: Array<Statement | ModuleDeclaration>;
66
- comments?: Array<Comment>;
67
- }
68
-
69
- interface BaseFunction extends BaseNode {
70
- params: Array<Pattern>;
71
- generator?: boolean;
72
- async?: boolean;
73
- // The body is either BlockStatement or Expression because arrow functions
74
- // can have a body that's either. FunctionDeclarations and
75
- // FunctionExpressions have only BlockStatement bodies.
76
- body: BlockStatement | Expression;
77
- }
78
-
79
- export type Function =
80
- FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
81
-
82
- export type Statement =
83
- ExpressionStatement | BlockStatement | EmptyStatement |
84
- DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement |
85
- BreakStatement | ContinueStatement | IfStatement | SwitchStatement |
86
- ThrowStatement | TryStatement | WhileStatement | DoWhileStatement |
87
- ForStatement | ForInStatement | ForOfStatement | Declaration;
88
-
89
- interface BaseStatement extends BaseNode { }
90
-
91
- export interface EmptyStatement extends BaseStatement {
92
- type: "EmptyStatement";
93
- }
94
-
95
- export interface BlockStatement extends BaseStatement {
96
- type: "BlockStatement";
97
- body: Array<Statement>;
98
- innerComments?: Array<Comment>;
99
- }
100
-
101
- export interface ExpressionStatement extends BaseStatement {
102
- type: "ExpressionStatement";
103
- expression: Expression;
104
- }
105
-
106
- export interface IfStatement extends BaseStatement {
107
- type: "IfStatement";
108
- test: Expression;
109
- consequent: Statement;
110
- alternate?: Statement | null;
111
- }
112
-
113
- export interface LabeledStatement extends BaseStatement {
114
- type: "LabeledStatement";
115
- label: Identifier;
116
- body: Statement;
117
- }
118
-
119
- export interface BreakStatement extends BaseStatement {
120
- type: "BreakStatement";
121
- label?: Identifier | null;
122
- }
123
-
124
- export interface ContinueStatement extends BaseStatement {
125
- type: "ContinueStatement";
126
- label?: Identifier | null;
127
- }
128
-
129
- export interface WithStatement extends BaseStatement {
130
- type: "WithStatement";
131
- object: Expression;
132
- body: Statement;
133
- }
134
-
135
- export interface SwitchStatement extends BaseStatement {
136
- type: "SwitchStatement";
137
- discriminant: Expression;
138
- cases: Array<SwitchCase>;
139
- }
140
-
141
- export interface ReturnStatement extends BaseStatement {
142
- type: "ReturnStatement";
143
- argument?: Expression | null;
144
- }
145
-
146
- export interface ThrowStatement extends BaseStatement {
147
- type: "ThrowStatement";
148
- argument: Expression;
149
- }
150
-
151
- export interface TryStatement extends BaseStatement {
152
- type: "TryStatement";
153
- block: BlockStatement;
154
- handler?: CatchClause | null;
155
- finalizer?: BlockStatement | null;
156
- }
157
-
158
- export interface WhileStatement extends BaseStatement {
159
- type: "WhileStatement";
160
- test: Expression;
161
- body: Statement;
162
- }
163
-
164
- export interface DoWhileStatement extends BaseStatement {
165
- type: "DoWhileStatement";
166
- body: Statement;
167
- test: Expression;
168
- }
169
-
170
- export interface ForStatement extends BaseStatement {
171
- type: "ForStatement";
172
- init?: VariableDeclaration | Expression | null;
173
- test?: Expression | null;
174
- update?: Expression | null;
175
- body: Statement;
176
- }
177
-
178
- interface BaseForXStatement extends BaseStatement {
179
- left: VariableDeclaration | Pattern;
180
- right: Expression;
181
- body: Statement;
182
- }
183
-
184
- export interface ForInStatement extends BaseForXStatement {
185
- type: "ForInStatement";
186
- }
187
-
188
- export interface DebuggerStatement extends BaseStatement {
189
- type: "DebuggerStatement";
190
- }
191
-
192
- export type Declaration =
193
- FunctionDeclaration | VariableDeclaration | ClassDeclaration;
194
-
195
- interface BaseDeclaration extends BaseStatement { }
196
-
197
- export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
198
- type: "FunctionDeclaration";
199
- /** It is null when a function declaration is a part of the `export default function` statement */
200
- id: Identifier | null;
201
- body: BlockStatement;
202
- }
203
-
204
- export interface VariableDeclaration extends BaseDeclaration {
205
- type: "VariableDeclaration";
206
- declarations: Array<VariableDeclarator>;
207
- kind: "var" | "let" | "const";
208
- }
209
-
210
- export interface VariableDeclarator extends BaseNode {
211
- type: "VariableDeclarator";
212
- id: Pattern;
213
- init?: Expression | null;
214
- }
215
-
216
- type Expression =
217
- ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression |
218
- ArrowFunctionExpression | YieldExpression | Literal | UnaryExpression |
219
- UpdateExpression | BinaryExpression | AssignmentExpression |
220
- LogicalExpression | MemberExpression | ConditionalExpression |
221
- CallExpression | NewExpression | SequenceExpression | TemplateLiteral |
222
- TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier |
223
- AwaitExpression;
224
-
225
- export interface BaseExpression extends BaseNode { }
226
-
227
- export interface ThisExpression extends BaseExpression {
228
- type: "ThisExpression";
229
- }
230
-
231
- export interface ArrayExpression extends BaseExpression {
232
- type: "ArrayExpression";
233
- elements: Array<Expression | SpreadElement>;
234
- }
235
-
236
- export interface ObjectExpression extends BaseExpression {
237
- type: "ObjectExpression";
238
- properties: Array<Property>;
239
- }
240
-
241
- export interface Property extends BaseNode {
242
- type: "Property";
243
- key: Expression;
244
- value: Expression | Pattern; // Could be an AssignmentProperty
245
- kind: "init" | "get" | "set";
246
- method: boolean;
247
- shorthand: boolean;
248
- computed: boolean;
249
- }
250
-
251
- export interface FunctionExpression extends BaseFunction, BaseExpression {
252
- id?: Identifier | null;
253
- type: "FunctionExpression";
254
- body: BlockStatement;
255
- }
256
-
257
- export interface SequenceExpression extends BaseExpression {
258
- type: "SequenceExpression";
259
- expressions: Array<Expression>;
260
- }
261
-
262
- export interface UnaryExpression extends BaseExpression {
263
- type: "UnaryExpression";
264
- operator: UnaryOperator;
265
- prefix: true;
266
- argument: Expression;
267
- }
268
-
269
- export interface BinaryExpression extends BaseExpression {
270
- type: "BinaryExpression";
271
- operator: BinaryOperator;
272
- left: Expression;
273
- right: Expression;
274
- }
275
-
276
- export interface AssignmentExpression extends BaseExpression {
277
- type: "AssignmentExpression";
278
- operator: AssignmentOperator;
279
- left: Pattern | MemberExpression;
280
- right: Expression;
281
- }
282
-
283
- export interface UpdateExpression extends BaseExpression {
284
- type: "UpdateExpression";
285
- operator: UpdateOperator;
286
- argument: Expression;
287
- prefix: boolean;
288
- }
289
-
290
- export interface LogicalExpression extends BaseExpression {
291
- type: "LogicalExpression";
292
- operator: LogicalOperator;
293
- left: Expression;
294
- right: Expression;
295
- }
296
-
297
- export interface ConditionalExpression extends BaseExpression {
298
- type: "ConditionalExpression";
299
- test: Expression;
300
- alternate: Expression;
301
- consequent: Expression;
302
- }
303
-
304
- interface BaseCallExpression extends BaseExpression {
305
- callee: Expression | Super;
306
- arguments: Array<Expression | SpreadElement>;
307
- }
308
- export type CallExpression = SimpleCallExpression | NewExpression;
309
-
310
- export interface SimpleCallExpression extends BaseCallExpression {
311
- type: "CallExpression";
312
- }
313
-
314
- export interface NewExpression extends BaseCallExpression {
315
- type: "NewExpression";
316
- }
317
-
318
- export interface MemberExpression extends BaseExpression, BasePattern {
319
- type: "MemberExpression";
320
- object: Expression | Super;
321
- property: Expression;
322
- computed: boolean;
323
- }
324
-
325
- export type Pattern =
326
- Identifier | ObjectPattern | ArrayPattern | RestElement |
327
- AssignmentPattern | MemberExpression;
328
-
329
- interface BasePattern extends BaseNode { }
330
-
331
- export interface SwitchCase extends BaseNode {
332
- type: "SwitchCase";
333
- test?: Expression | null;
334
- consequent: Array<Statement>;
335
- }
336
-
337
- export interface CatchClause extends BaseNode {
338
- type: "CatchClause";
339
- param: Pattern;
340
- body: BlockStatement;
341
- }
342
-
343
- export interface Identifier extends BaseNode, BaseExpression, BasePattern {
344
- type: "Identifier";
345
- name: string;
346
- }
347
-
348
- export type Literal = SimpleLiteral | RegExpLiteral;
349
-
350
- export interface SimpleLiteral extends BaseNode, BaseExpression {
351
- type: "Literal";
352
- value: string | boolean | number | null;
353
- raw?: string;
354
- }
355
-
356
- export interface RegExpLiteral extends BaseNode, BaseExpression {
357
- type: "Literal";
358
- value?: RegExp | null;
359
- regex: {
360
- pattern: string;
361
- flags: string;
362
- };
363
- raw?: string;
364
- }
365
-
366
- export type UnaryOperator =
367
- "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
368
-
369
- export type BinaryOperator =
370
- "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" |
371
- ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" |
372
- "instanceof";
373
-
374
- export type LogicalOperator = "||" | "&&";
375
-
376
- export type AssignmentOperator =
377
- "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" |
378
- "|=" | "^=" | "&=";
379
-
380
- export type UpdateOperator = "++" | "--";
381
-
382
- export interface ForOfStatement extends BaseForXStatement {
383
- type: "ForOfStatement";
384
- }
385
-
386
- export interface Super extends BaseNode {
387
- type: "Super";
388
- }
389
-
390
- export interface SpreadElement extends BaseNode {
391
- type: "SpreadElement";
392
- argument: Expression;
393
- }
394
-
395
- export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
396
- type: "ArrowFunctionExpression";
397
- expression: boolean;
398
- body: BlockStatement | Expression;
399
- }
400
-
401
- export interface YieldExpression extends BaseExpression {
402
- type: "YieldExpression";
403
- argument?: Expression | null;
404
- delegate: boolean;
405
- }
406
-
407
- export interface TemplateLiteral extends BaseExpression {
408
- type: "TemplateLiteral";
409
- quasis: Array<TemplateElement>;
410
- expressions: Array<Expression>;
411
- }
412
-
413
- export interface TaggedTemplateExpression extends BaseExpression {
414
- type: "TaggedTemplateExpression";
415
- tag: Expression;
416
- quasi: TemplateLiteral;
417
- }
418
-
419
- export interface TemplateElement extends BaseNode {
420
- type: "TemplateElement";
421
- tail: boolean;
422
- value: {
423
- cooked: string;
424
- raw: string;
425
- };
426
- }
427
-
428
- export interface AssignmentProperty extends Property {
429
- value: Pattern;
430
- kind: "init";
431
- method: boolean; // false
432
- }
433
-
434
- export interface ObjectPattern extends BasePattern {
435
- type: "ObjectPattern";
436
- properties: Array<AssignmentProperty>;
437
- }
438
-
439
- export interface ArrayPattern extends BasePattern {
440
- type: "ArrayPattern";
441
- elements: Array<Pattern>;
442
- }
443
-
444
- export interface RestElement extends BasePattern {
445
- type: "RestElement";
446
- argument: Pattern;
447
- }
448
-
449
- export interface AssignmentPattern extends BasePattern {
450
- type: "AssignmentPattern";
451
- left: Pattern;
452
- right: Expression;
453
- }
454
-
455
- export type Class = ClassDeclaration | ClassExpression;
456
- interface BaseClass extends BaseNode {
457
- superClass?: Expression | null;
458
- body: ClassBody;
459
- }
460
-
461
- export interface ClassBody extends BaseNode {
462
- type: "ClassBody";
463
- body: Array<MethodDefinition>;
464
- }
465
-
466
- export interface MethodDefinition extends BaseNode {
467
- type: "MethodDefinition";
468
- key: Expression;
469
- value: FunctionExpression;
470
- kind: "constructor" | "method" | "get" | "set";
471
- computed: boolean;
472
- static: boolean;
473
- }
474
-
475
- export interface ClassDeclaration extends BaseClass, BaseDeclaration {
476
- type: "ClassDeclaration";
477
- /** It is null when a class declaration is a part of the `export default class` statement */
478
- id: Identifier | null;
479
- }
480
-
481
- export interface ClassExpression extends BaseClass, BaseExpression {
482
- type: "ClassExpression";
483
- id?: Identifier | null;
484
- }
485
-
486
- export interface MetaProperty extends BaseExpression {
487
- type: "MetaProperty";
488
- meta: Identifier;
489
- property: Identifier;
490
- }
491
-
492
- export type ModuleDeclaration =
493
- ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration |
494
- ExportAllDeclaration;
495
- interface BaseModuleDeclaration extends BaseNode { }
496
-
497
- export type ModuleSpecifier =
498
- ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier |
499
- ExportSpecifier;
500
- interface BaseModuleSpecifier extends BaseNode {
501
- local: Identifier;
502
- }
503
-
504
- export interface ImportDeclaration extends BaseModuleDeclaration {
505
- type: "ImportDeclaration";
506
- specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
507
- source: Literal;
508
- }
509
-
510
- export interface ImportSpecifier extends BaseModuleSpecifier {
511
- type: "ImportSpecifier";
512
- imported: Identifier;
513
- }
514
-
515
- export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
516
- type: "ImportDefaultSpecifier";
517
- }
518
-
519
- export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
520
- type: "ImportNamespaceSpecifier";
521
- }
522
-
523
- export interface ExportNamedDeclaration extends BaseModuleDeclaration {
524
- type: "ExportNamedDeclaration";
525
- declaration?: Declaration | null;
526
- specifiers: Array<ExportSpecifier>;
527
- source?: Literal | null;
528
- }
529
-
530
- export interface ExportSpecifier extends BaseModuleSpecifier {
531
- type: "ExportSpecifier";
532
- exported: Identifier;
533
- }
534
-
535
- export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
536
- type: "ExportDefaultDeclaration";
537
- declaration: Declaration | Expression;
538
- }
539
-
540
- export interface ExportAllDeclaration extends BaseModuleDeclaration {
541
- type: "ExportAllDeclaration";
542
- source: Literal;
543
- }
544
-
545
- export interface AwaitExpression extends BaseExpression {
546
- type: "AwaitExpression";
547
- argument: Expression;
548
- }
1
+ // Type definitions for non-npm package estree 1.0
2
+ // Project: https://github.com/estree/estree
3
+ // Definitions by: RReverser <https://github.com/RReverser>
4
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+
6
+ // This definition file follows a somewhat unusual format. ESTree allows
7
+ // runtime type checks based on the `type` parameter. In order to explain this
8
+ // to typescript we want to use discriminated union types:
9
+ // https://github.com/Microsoft/TypeScript/pull/9163
10
+ //
11
+ // For ESTree this is a bit tricky because the high level interfaces like
12
+ // Node or Function are pulling double duty. We want to pass common fields down
13
+ // to the interfaces that extend them (like Identifier or
14
+ // ArrowFunctionExpression), but you can't extend a type union or enforce
15
+ // common fields on them. So we've split the high level interfaces into two
16
+ // types, a base type which passes down inherited fields, and a type union of
17
+ // all types which extend the base type. Only the type union is exported, and
18
+ // the union is how other types refer to the collection of inheriting types.
19
+ //
20
+ // This makes the definitions file here somewhat more difficult to maintain,
21
+ // but it has the notable advantage of making ESTree much easier to use as
22
+ // an end user.
23
+
24
+ export interface BaseNodeWithoutComments {
25
+ // Every leaf interface that extends BaseNode must specify a type property.
26
+ // The type property should be a string literal. For example, Identifier
27
+ // has: `type: "Identifier"`
28
+ type: string;
29
+ loc?: SourceLocation | null | undefined;
30
+ range?: [number, number] | undefined;
31
+ }
32
+
33
+ export interface BaseNode extends BaseNodeWithoutComments {
34
+ leadingComments?: Comment[] | undefined;
35
+ trailingComments?: Comment[] | undefined;
36
+ }
37
+
38
+ export interface NodeMap {
39
+ AssignmentProperty: AssignmentProperty;
40
+ CatchClause: CatchClause;
41
+ Class: Class;
42
+ ClassBody: ClassBody;
43
+ Expression: Expression;
44
+ Function: Function;
45
+ Identifier: Identifier;
46
+ Literal: Literal;
47
+ MethodDefinition: MethodDefinition;
48
+ ModuleDeclaration: ModuleDeclaration;
49
+ ModuleSpecifier: ModuleSpecifier;
50
+ Pattern: Pattern;
51
+ PrivateIdentifier: PrivateIdentifier;
52
+ Program: Program;
53
+ Property: Property;
54
+ PropertyDefinition: PropertyDefinition;
55
+ SpreadElement: SpreadElement;
56
+ Statement: Statement;
57
+ Super: Super;
58
+ SwitchCase: SwitchCase;
59
+ TemplateElement: TemplateElement;
60
+ VariableDeclarator: VariableDeclarator;
61
+ }
62
+
63
+ export type Node = NodeMap[keyof NodeMap];
64
+
65
+ export interface Comment extends BaseNodeWithoutComments {
66
+ type: 'Line' | 'Block';
67
+ value: string;
68
+ }
69
+
70
+ export interface SourceLocation {
71
+ source?: string | null | undefined;
72
+ start: Position;
73
+ end: Position;
74
+ }
75
+
76
+ export interface Position {
77
+ /** >= 1 */
78
+ line: number;
79
+ /** >= 0 */
80
+ column: number;
81
+ }
82
+
83
+ export interface Program extends BaseNode {
84
+ type: 'Program';
85
+ sourceType: 'script' | 'module';
86
+ body: Array<Directive | Statement | ModuleDeclaration>;
87
+ comments?: Comment[] | undefined;
88
+ }
89
+
90
+ export interface Directive extends BaseNode {
91
+ type: 'ExpressionStatement';
92
+ expression: Literal;
93
+ directive: string;
94
+ }
95
+
96
+ export interface BaseFunction extends BaseNode {
97
+ params: Pattern[];
98
+ generator?: boolean | undefined;
99
+ async?: boolean | undefined;
100
+ // The body is either BlockStatement or Expression because arrow functions
101
+ // can have a body that's either. FunctionDeclarations and
102
+ // FunctionExpressions have only BlockStatement bodies.
103
+ body: BlockStatement | Expression;
104
+ }
105
+
106
+ export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
107
+
108
+ export type Statement =
109
+ | ExpressionStatement
110
+ | BlockStatement
111
+ | StaticBlock
112
+ | EmptyStatement
113
+ | DebuggerStatement
114
+ | WithStatement
115
+ | ReturnStatement
116
+ | LabeledStatement
117
+ | BreakStatement
118
+ | ContinueStatement
119
+ | IfStatement
120
+ | SwitchStatement
121
+ | ThrowStatement
122
+ | TryStatement
123
+ | WhileStatement
124
+ | DoWhileStatement
125
+ | ForStatement
126
+ | ForInStatement
127
+ | ForOfStatement
128
+ | Declaration;
129
+
130
+ export interface BaseStatement extends BaseNode {}
131
+
132
+ export interface EmptyStatement extends BaseStatement {
133
+ type: 'EmptyStatement';
134
+ }
135
+
136
+ export interface BlockStatement extends BaseStatement {
137
+ type: 'BlockStatement';
138
+ body: Statement[];
139
+ innerComments?: Comment[] | undefined;
140
+ }
141
+
142
+ export interface StaticBlock extends Omit<BlockStatement, 'type'> {
143
+ type: 'StaticBlock';
144
+ }
145
+
146
+ export interface ExpressionStatement extends BaseStatement {
147
+ type: 'ExpressionStatement';
148
+ expression: Expression;
149
+ }
150
+
151
+ export interface IfStatement extends BaseStatement {
152
+ type: 'IfStatement';
153
+ test: Expression;
154
+ consequent: Statement;
155
+ alternate?: Statement | null | undefined;
156
+ }
157
+
158
+ export interface LabeledStatement extends BaseStatement {
159
+ type: 'LabeledStatement';
160
+ label: Identifier;
161
+ body: Statement;
162
+ }
163
+
164
+ export interface BreakStatement extends BaseStatement {
165
+ type: 'BreakStatement';
166
+ label?: Identifier | null | undefined;
167
+ }
168
+
169
+ export interface ContinueStatement extends BaseStatement {
170
+ type: 'ContinueStatement';
171
+ label?: Identifier | null | undefined;
172
+ }
173
+
174
+ export interface WithStatement extends BaseStatement {
175
+ type: 'WithStatement';
176
+ object: Expression;
177
+ body: Statement;
178
+ }
179
+
180
+ export interface SwitchStatement extends BaseStatement {
181
+ type: 'SwitchStatement';
182
+ discriminant: Expression;
183
+ cases: SwitchCase[];
184
+ }
185
+
186
+ export interface ReturnStatement extends BaseStatement {
187
+ type: 'ReturnStatement';
188
+ argument?: Expression | null | undefined;
189
+ }
190
+
191
+ export interface ThrowStatement extends BaseStatement {
192
+ type: 'ThrowStatement';
193
+ argument: Expression;
194
+ }
195
+
196
+ export interface TryStatement extends BaseStatement {
197
+ type: 'TryStatement';
198
+ block: BlockStatement;
199
+ handler?: CatchClause | null | undefined;
200
+ finalizer?: BlockStatement | null | undefined;
201
+ }
202
+
203
+ export interface WhileStatement extends BaseStatement {
204
+ type: 'WhileStatement';
205
+ test: Expression;
206
+ body: Statement;
207
+ }
208
+
209
+ export interface DoWhileStatement extends BaseStatement {
210
+ type: 'DoWhileStatement';
211
+ body: Statement;
212
+ test: Expression;
213
+ }
214
+
215
+ export interface ForStatement extends BaseStatement {
216
+ type: 'ForStatement';
217
+ init?: VariableDeclaration | Expression | null | undefined;
218
+ test?: Expression | null | undefined;
219
+ update?: Expression | null | undefined;
220
+ body: Statement;
221
+ }
222
+
223
+ export interface BaseForXStatement extends BaseStatement {
224
+ left: VariableDeclaration | Pattern;
225
+ right: Expression;
226
+ body: Statement;
227
+ }
228
+
229
+ export interface ForInStatement extends BaseForXStatement {
230
+ type: 'ForInStatement';
231
+ }
232
+
233
+ export interface DebuggerStatement extends BaseStatement {
234
+ type: 'DebuggerStatement';
235
+ }
236
+
237
+ export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
238
+
239
+ export interface BaseDeclaration extends BaseStatement {}
240
+
241
+ export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
242
+ type: 'FunctionDeclaration';
243
+ /** It is null when a function declaration is a part of the `export default function` statement */
244
+ id: Identifier | null;
245
+ body: BlockStatement;
246
+ }
247
+
248
+ export interface VariableDeclaration extends BaseDeclaration {
249
+ type: 'VariableDeclaration';
250
+ declarations: VariableDeclarator[];
251
+ kind: 'var' | 'let' | 'const';
252
+ }
253
+
254
+ export interface VariableDeclarator extends BaseNode {
255
+ type: 'VariableDeclarator';
256
+ id: Pattern;
257
+ init?: Expression | null | undefined;
258
+ }
259
+
260
+ export interface ExpressionMap {
261
+ ArrayExpression: ArrayExpression;
262
+ ArrowFunctionExpression: ArrowFunctionExpression;
263
+ AssignmentExpression: AssignmentExpression;
264
+ AwaitExpression: AwaitExpression;
265
+ BinaryExpression: BinaryExpression;
266
+ CallExpression: CallExpression;
267
+ ChainExpression: ChainExpression;
268
+ ClassExpression: ClassExpression;
269
+ ConditionalExpression: ConditionalExpression;
270
+ FunctionExpression: FunctionExpression;
271
+ Identifier: Identifier;
272
+ ImportExpression: ImportExpression;
273
+ Literal: Literal;
274
+ LogicalExpression: LogicalExpression;
275
+ MemberExpression: MemberExpression;
276
+ MetaProperty: MetaProperty;
277
+ NewExpression: NewExpression;
278
+ ObjectExpression: ObjectExpression;
279
+ SequenceExpression: SequenceExpression;
280
+ TaggedTemplateExpression: TaggedTemplateExpression;
281
+ TemplateLiteral: TemplateLiteral;
282
+ ThisExpression: ThisExpression;
283
+ UnaryExpression: UnaryExpression;
284
+ UpdateExpression: UpdateExpression;
285
+ YieldExpression: YieldExpression;
286
+ }
287
+
288
+ export type Expression = ExpressionMap[keyof ExpressionMap];
289
+
290
+ export interface BaseExpression extends BaseNode {}
291
+
292
+ export type ChainElement = SimpleCallExpression | MemberExpression;
293
+
294
+ export interface ChainExpression extends BaseExpression {
295
+ type: 'ChainExpression';
296
+ expression: ChainElement;
297
+ }
298
+
299
+ export interface ThisExpression extends BaseExpression {
300
+ type: 'ThisExpression';
301
+ }
302
+
303
+ export interface ArrayExpression extends BaseExpression {
304
+ type: 'ArrayExpression';
305
+ elements: Array<Expression | SpreadElement | null>;
306
+ }
307
+
308
+ export interface ObjectExpression extends BaseExpression {
309
+ type: 'ObjectExpression';
310
+ properties: Array<Property | SpreadElement>;
311
+ }
312
+
313
+ export interface PrivateIdentifier extends BaseNode {
314
+ type: 'PrivateIdentifier';
315
+ name: string;
316
+ }
317
+
318
+ export interface Property extends BaseNode {
319
+ type: 'Property';
320
+ key: Expression | PrivateIdentifier;
321
+ value: Expression | Pattern; // Could be an AssignmentProperty
322
+ kind: 'init' | 'get' | 'set';
323
+ method: boolean;
324
+ shorthand: boolean;
325
+ computed: boolean;
326
+ }
327
+
328
+ export interface PropertyDefinition extends BaseNode {
329
+ type: 'PropertyDefinition';
330
+ key: Expression | PrivateIdentifier;
331
+ value?: Expression | null | undefined;
332
+ computed: boolean;
333
+ static: boolean;
334
+ }
335
+
336
+ export interface FunctionExpression extends BaseFunction, BaseExpression {
337
+ id?: Identifier | null | undefined;
338
+ type: 'FunctionExpression';
339
+ body: BlockStatement;
340
+ }
341
+
342
+ export interface SequenceExpression extends BaseExpression {
343
+ type: 'SequenceExpression';
344
+ expressions: Expression[];
345
+ }
346
+
347
+ export interface UnaryExpression extends BaseExpression {
348
+ type: 'UnaryExpression';
349
+ operator: UnaryOperator;
350
+ prefix: true;
351
+ argument: Expression;
352
+ }
353
+
354
+ export interface BinaryExpression extends BaseExpression {
355
+ type: 'BinaryExpression';
356
+ operator: BinaryOperator;
357
+ left: Expression;
358
+ right: Expression;
359
+ }
360
+
361
+ export interface AssignmentExpression extends BaseExpression {
362
+ type: 'AssignmentExpression';
363
+ operator: AssignmentOperator;
364
+ left: Pattern | MemberExpression;
365
+ right: Expression;
366
+ }
367
+
368
+ export interface UpdateExpression extends BaseExpression {
369
+ type: 'UpdateExpression';
370
+ operator: UpdateOperator;
371
+ argument: Expression;
372
+ prefix: boolean;
373
+ }
374
+
375
+ export interface LogicalExpression extends BaseExpression {
376
+ type: 'LogicalExpression';
377
+ operator: LogicalOperator;
378
+ left: Expression;
379
+ right: Expression;
380
+ }
381
+
382
+ export interface ConditionalExpression extends BaseExpression {
383
+ type: 'ConditionalExpression';
384
+ test: Expression;
385
+ alternate: Expression;
386
+ consequent: Expression;
387
+ }
388
+
389
+ export interface BaseCallExpression extends BaseExpression {
390
+ callee: Expression | Super;
391
+ arguments: Array<Expression | SpreadElement>;
392
+ }
393
+ export type CallExpression = SimpleCallExpression | NewExpression;
394
+
395
+ export interface SimpleCallExpression extends BaseCallExpression {
396
+ type: 'CallExpression';
397
+ optional: boolean;
398
+ }
399
+
400
+ export interface NewExpression extends BaseCallExpression {
401
+ type: 'NewExpression';
402
+ }
403
+
404
+ export interface MemberExpression extends BaseExpression, BasePattern {
405
+ type: 'MemberExpression';
406
+ object: Expression | Super;
407
+ property: Expression | PrivateIdentifier;
408
+ computed: boolean;
409
+ optional: boolean;
410
+ }
411
+
412
+ export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
413
+
414
+ export interface BasePattern extends BaseNode {}
415
+
416
+ export interface SwitchCase extends BaseNode {
417
+ type: 'SwitchCase';
418
+ test?: Expression | null | undefined;
419
+ consequent: Statement[];
420
+ }
421
+
422
+ export interface CatchClause extends BaseNode {
423
+ type: 'CatchClause';
424
+ param: Pattern | null;
425
+ body: BlockStatement;
426
+ }
427
+
428
+ export interface Identifier extends BaseNode, BaseExpression, BasePattern {
429
+ type: 'Identifier';
430
+ name: string;
431
+ }
432
+
433
+ export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
434
+
435
+ export interface SimpleLiteral extends BaseNode, BaseExpression {
436
+ type: 'Literal';
437
+ value: string | boolean | number | null;
438
+ raw?: string | undefined;
439
+ }
440
+
441
+ export interface RegExpLiteral extends BaseNode, BaseExpression {
442
+ type: 'Literal';
443
+ value?: RegExp | null | undefined;
444
+ regex: {
445
+ pattern: string;
446
+ flags: string;
447
+ };
448
+ raw?: string | undefined;
449
+ }
450
+
451
+ export interface BigIntLiteral extends BaseNode, BaseExpression {
452
+ type: 'Literal';
453
+ value?: bigint | null | undefined;
454
+ bigint: string;
455
+ raw?: string | undefined;
456
+ }
457
+
458
+ export type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';
459
+
460
+ export type BinaryOperator =
461
+ | '=='
462
+ | '!='
463
+ | '==='
464
+ | '!=='
465
+ | '<'
466
+ | '<='
467
+ | '>'
468
+ | '>='
469
+ | '<<'
470
+ | '>>'
471
+ | '>>>'
472
+ | '+'
473
+ | '-'
474
+ | '*'
475
+ | '/'
476
+ | '%'
477
+ | '**'
478
+ | '|'
479
+ | '^'
480
+ | '&'
481
+ | 'in'
482
+ | 'instanceof';
483
+
484
+ export type LogicalOperator = '||' | '&&' | '??';
485
+
486
+ export type AssignmentOperator =
487
+ | '='
488
+ | '+='
489
+ | '-='
490
+ | '*='
491
+ | '/='
492
+ | '%='
493
+ | '**='
494
+ | '<<='
495
+ | '>>='
496
+ | '>>>='
497
+ | '|='
498
+ | '^='
499
+ | '&=';
500
+
501
+ export type UpdateOperator = '++' | '--';
502
+
503
+ export interface ForOfStatement extends BaseForXStatement {
504
+ type: 'ForOfStatement';
505
+ await: boolean;
506
+ }
507
+
508
+ export interface Super extends BaseNode {
509
+ type: 'Super';
510
+ }
511
+
512
+ export interface SpreadElement extends BaseNode {
513
+ type: 'SpreadElement';
514
+ argument: Expression;
515
+ }
516
+
517
+ export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
518
+ type: 'ArrowFunctionExpression';
519
+ expression: boolean;
520
+ body: BlockStatement | Expression;
521
+ }
522
+
523
+ export interface YieldExpression extends BaseExpression {
524
+ type: 'YieldExpression';
525
+ argument?: Expression | null | undefined;
526
+ delegate: boolean;
527
+ }
528
+
529
+ export interface TemplateLiteral extends BaseExpression {
530
+ type: 'TemplateLiteral';
531
+ quasis: TemplateElement[];
532
+ expressions: Expression[];
533
+ }
534
+
535
+ export interface TaggedTemplateExpression extends BaseExpression {
536
+ type: 'TaggedTemplateExpression';
537
+ tag: Expression;
538
+ quasi: TemplateLiteral;
539
+ }
540
+
541
+ export interface TemplateElement extends BaseNode {
542
+ type: 'TemplateElement';
543
+ tail: boolean;
544
+ value: {
545
+ /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
546
+ cooked?: string | null | undefined;
547
+ raw: string;
548
+ };
549
+ }
550
+
551
+ export interface AssignmentProperty extends Property {
552
+ value: Pattern;
553
+ kind: 'init';
554
+ method: boolean; // false
555
+ }
556
+
557
+ export interface ObjectPattern extends BasePattern {
558
+ type: 'ObjectPattern';
559
+ properties: Array<AssignmentProperty | RestElement>;
560
+ }
561
+
562
+ export interface ArrayPattern extends BasePattern {
563
+ type: 'ArrayPattern';
564
+ elements: Array<Pattern | null>;
565
+ }
566
+
567
+ export interface RestElement extends BasePattern {
568
+ type: 'RestElement';
569
+ argument: Pattern;
570
+ }
571
+
572
+ export interface AssignmentPattern extends BasePattern {
573
+ type: 'AssignmentPattern';
574
+ left: Pattern;
575
+ right: Expression;
576
+ }
577
+
578
+ export type Class = ClassDeclaration | ClassExpression;
579
+ export interface BaseClass extends BaseNode {
580
+ superClass?: Expression | null | undefined;
581
+ body: ClassBody;
582
+ }
583
+
584
+ export interface ClassBody extends BaseNode {
585
+ type: 'ClassBody';
586
+ body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
587
+ }
588
+
589
+ export interface MethodDefinition extends BaseNode {
590
+ type: 'MethodDefinition';
591
+ key: Expression | PrivateIdentifier;
592
+ value: FunctionExpression;
593
+ kind: 'constructor' | 'method' | 'get' | 'set';
594
+ computed: boolean;
595
+ static: boolean;
596
+ }
597
+
598
+ export interface ClassDeclaration extends BaseClass, BaseDeclaration {
599
+ type: 'ClassDeclaration';
600
+ /** It is null when a class declaration is a part of the `export default class` statement */
601
+ id: Identifier | null;
602
+ }
603
+
604
+ export interface ClassExpression extends BaseClass, BaseExpression {
605
+ type: 'ClassExpression';
606
+ id?: Identifier | null | undefined;
607
+ }
608
+
609
+ export interface MetaProperty extends BaseExpression {
610
+ type: 'MetaProperty';
611
+ meta: Identifier;
612
+ property: Identifier;
613
+ }
614
+
615
+ export type ModuleDeclaration =
616
+ | ImportDeclaration
617
+ | ExportNamedDeclaration
618
+ | ExportDefaultDeclaration
619
+ | ExportAllDeclaration;
620
+ export interface BaseModuleDeclaration extends BaseNode {}
621
+
622
+ export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
623
+ export interface BaseModuleSpecifier extends BaseNode {
624
+ local: Identifier;
625
+ }
626
+
627
+ export interface ImportDeclaration extends BaseModuleDeclaration {
628
+ type: 'ImportDeclaration';
629
+ specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
630
+ source: Literal;
631
+ }
632
+
633
+ export interface ImportSpecifier extends BaseModuleSpecifier {
634
+ type: 'ImportSpecifier';
635
+ imported: Identifier;
636
+ }
637
+
638
+ export interface ImportExpression extends BaseExpression {
639
+ type: 'ImportExpression';
640
+ source: Expression;
641
+ }
642
+
643
+ export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
644
+ type: 'ImportDefaultSpecifier';
645
+ }
646
+
647
+ export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
648
+ type: 'ImportNamespaceSpecifier';
649
+ }
650
+
651
+ export interface ExportNamedDeclaration extends BaseModuleDeclaration {
652
+ type: 'ExportNamedDeclaration';
653
+ declaration?: Declaration | null | undefined;
654
+ specifiers: ExportSpecifier[];
655
+ source?: Literal | null | undefined;
656
+ }
657
+
658
+ export interface ExportSpecifier extends BaseModuleSpecifier {
659
+ type: 'ExportSpecifier';
660
+ exported: Identifier;
661
+ }
662
+
663
+ export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
664
+ type: 'ExportDefaultDeclaration';
665
+ declaration: Declaration | Expression;
666
+ }
667
+
668
+ export interface ExportAllDeclaration extends BaseModuleDeclaration {
669
+ type: 'ExportAllDeclaration';
670
+ exported: Identifier | null;
671
+ source: Literal;
672
+ }
673
+
674
+ export interface AwaitExpression extends BaseExpression {
675
+ type: 'AwaitExpression';
676
+ argument: Expression;
677
+ }