1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | interface BaseNodeWithoutComments {
|
25 |
|
26 |
|
27 |
|
28 | type: string;
|
29 | loc?: SourceLocation | null | undefined;
|
30 | range?: [number, number] | undefined;
|
31 | }
|
32 |
|
33 | interface BaseNode extends BaseNodeWithoutComments {
|
34 | leadingComments?: Array<Comment> | undefined;
|
35 | trailingComments?: Array<Comment> | undefined;
|
36 | }
|
37 |
|
38 | export type Node =
|
39 | Identifier | Literal | Program | Function | SwitchCase | CatchClause |
|
40 | VariableDeclarator | Statement | Expression | PrivateIdentifier | Property | PropertyDefinition |
|
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 | undefined;
|
51 | start: Position;
|
52 | end: Position;
|
53 | }
|
54 |
|
55 | export interface Position {
|
56 |
|
57 | line: number;
|
58 |
|
59 | column: number;
|
60 | }
|
61 |
|
62 | export interface Program extends BaseNode {
|
63 | type: "Program";
|
64 | sourceType: "script" | "module";
|
65 | body: Array<Directive | Statement | ModuleDeclaration>;
|
66 | comments?: Array<Comment> | undefined;
|
67 | }
|
68 |
|
69 | export interface Directive extends BaseNode {
|
70 | type: "ExpressionStatement";
|
71 | expression: Literal;
|
72 | directive: string;
|
73 | }
|
74 |
|
75 | interface BaseFunction extends BaseNode {
|
76 | params: Array<Pattern>;
|
77 | generator?: boolean | undefined;
|
78 | async?: boolean | undefined;
|
79 |
|
80 |
|
81 |
|
82 | body: BlockStatement | Expression;
|
83 | }
|
84 |
|
85 | export type Function =
|
86 | FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
87 |
|
88 | export type Statement =
|
89 | ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement |
|
90 | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement |
|
91 | BreakStatement | ContinueStatement | IfStatement | SwitchStatement |
|
92 | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement |
|
93 | ForStatement | ForInStatement | ForOfStatement | Declaration;
|
94 |
|
95 | interface BaseStatement extends BaseNode { }
|
96 |
|
97 | export interface EmptyStatement extends BaseStatement {
|
98 | type: "EmptyStatement";
|
99 | }
|
100 |
|
101 | export interface BlockStatement extends BaseStatement {
|
102 | type: "BlockStatement";
|
103 | body: Array<Statement>;
|
104 | innerComments?: Array<Comment> | undefined;
|
105 | }
|
106 |
|
107 | export interface StaticBlock extends Omit<BlockStatement, 'type'> {
|
108 | type: "StaticBlock";
|
109 | }
|
110 |
|
111 | export interface ExpressionStatement extends BaseStatement {
|
112 | type: "ExpressionStatement";
|
113 | expression: Expression;
|
114 | }
|
115 |
|
116 | export interface IfStatement extends BaseStatement {
|
117 | type: "IfStatement";
|
118 | test: Expression;
|
119 | consequent: Statement;
|
120 | alternate?: Statement | null | undefined;
|
121 | }
|
122 |
|
123 | export interface LabeledStatement extends BaseStatement {
|
124 | type: "LabeledStatement";
|
125 | label: Identifier;
|
126 | body: Statement;
|
127 | }
|
128 |
|
129 | export interface BreakStatement extends BaseStatement {
|
130 | type: "BreakStatement";
|
131 | label?: Identifier | null | undefined;
|
132 | }
|
133 |
|
134 | export interface ContinueStatement extends BaseStatement {
|
135 | type: "ContinueStatement";
|
136 | label?: Identifier | null | undefined;
|
137 | }
|
138 |
|
139 | export interface WithStatement extends BaseStatement {
|
140 | type: "WithStatement";
|
141 | object: Expression;
|
142 | body: Statement;
|
143 | }
|
144 |
|
145 | export interface SwitchStatement extends BaseStatement {
|
146 | type: "SwitchStatement";
|
147 | discriminant: Expression;
|
148 | cases: Array<SwitchCase>;
|
149 | }
|
150 |
|
151 | export interface ReturnStatement extends BaseStatement {
|
152 | type: "ReturnStatement";
|
153 | argument?: Expression | null | undefined;
|
154 | }
|
155 |
|
156 | export interface ThrowStatement extends BaseStatement {
|
157 | type: "ThrowStatement";
|
158 | argument: Expression;
|
159 | }
|
160 |
|
161 | export interface TryStatement extends BaseStatement {
|
162 | type: "TryStatement";
|
163 | block: BlockStatement;
|
164 | handler?: CatchClause | null | undefined;
|
165 | finalizer?: BlockStatement | null | undefined;
|
166 | }
|
167 |
|
168 | export interface WhileStatement extends BaseStatement {
|
169 | type: "WhileStatement";
|
170 | test: Expression;
|
171 | body: Statement;
|
172 | }
|
173 |
|
174 | export interface DoWhileStatement extends BaseStatement {
|
175 | type: "DoWhileStatement";
|
176 | body: Statement;
|
177 | test: Expression;
|
178 | }
|
179 |
|
180 | export interface ForStatement extends BaseStatement {
|
181 | type: "ForStatement";
|
182 | init?: VariableDeclaration | Expression | null | undefined;
|
183 | test?: Expression | null | undefined;
|
184 | update?: Expression | null | undefined;
|
185 | body: Statement;
|
186 | }
|
187 |
|
188 | interface BaseForXStatement extends BaseStatement {
|
189 | left: VariableDeclaration | Pattern;
|
190 | right: Expression;
|
191 | body: Statement;
|
192 | }
|
193 |
|
194 | export interface ForInStatement extends BaseForXStatement {
|
195 | type: "ForInStatement";
|
196 | }
|
197 |
|
198 | export interface DebuggerStatement extends BaseStatement {
|
199 | type: "DebuggerStatement";
|
200 | }
|
201 |
|
202 | export type Declaration =
|
203 | FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
204 |
|
205 | interface BaseDeclaration extends BaseStatement { }
|
206 |
|
207 | export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
|
208 | type: "FunctionDeclaration";
|
209 |
|
210 | id: Identifier | null;
|
211 | body: BlockStatement;
|
212 | }
|
213 |
|
214 | export interface VariableDeclaration extends BaseDeclaration {
|
215 | type: "VariableDeclaration";
|
216 | declarations: Array<VariableDeclarator>;
|
217 | kind: "var" | "let" | "const";
|
218 | }
|
219 |
|
220 | export interface VariableDeclarator extends BaseNode {
|
221 | type: "VariableDeclarator";
|
222 | id: Pattern;
|
223 | init?: Expression | null | undefined;
|
224 | }
|
225 |
|
226 | type Expression =
|
227 | ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression |
|
228 | ArrowFunctionExpression | YieldExpression | Literal | UnaryExpression |
|
229 | UpdateExpression | BinaryExpression | AssignmentExpression |
|
230 | LogicalExpression | MemberExpression | ConditionalExpression |
|
231 | CallExpression | NewExpression | SequenceExpression | TemplateLiteral |
|
232 | TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier |
|
233 | AwaitExpression | ImportExpression | ChainExpression;
|
234 |
|
235 | export interface BaseExpression extends BaseNode { }
|
236 |
|
237 | type ChainElement = SimpleCallExpression | MemberExpression;
|
238 |
|
239 | export interface ChainExpression extends BaseExpression {
|
240 | type: "ChainExpression";
|
241 | expression: ChainElement;
|
242 | }
|
243 |
|
244 | export interface ThisExpression extends BaseExpression {
|
245 | type: "ThisExpression";
|
246 | }
|
247 |
|
248 | export interface ArrayExpression extends BaseExpression {
|
249 | type: "ArrayExpression";
|
250 | elements: Array<Expression | SpreadElement | null>;
|
251 | }
|
252 |
|
253 | export interface ObjectExpression extends BaseExpression {
|
254 | type: "ObjectExpression";
|
255 | properties: Array<Property | SpreadElement>;
|
256 | }
|
257 |
|
258 | export interface PrivateIdentifier extends BaseNode {
|
259 | type: "PrivateIdentifier";
|
260 | name: string;
|
261 | }
|
262 |
|
263 | export interface Property extends BaseNode {
|
264 | type: "Property";
|
265 | key: Expression | PrivateIdentifier;
|
266 | value: Expression | Pattern;
|
267 | kind: "init" | "get" | "set";
|
268 | method: boolean;
|
269 | shorthand: boolean;
|
270 | computed: boolean;
|
271 | }
|
272 |
|
273 | export interface PropertyDefinition extends BaseNode {
|
274 | type: "PropertyDefinition";
|
275 | key: Expression | PrivateIdentifier;
|
276 | value?: Expression | null | undefined;
|
277 | computed: boolean;
|
278 | static: boolean;
|
279 | }
|
280 |
|
281 | export interface FunctionExpression extends BaseFunction, BaseExpression {
|
282 | id?: Identifier | null | undefined;
|
283 | type: "FunctionExpression";
|
284 | body: BlockStatement;
|
285 | }
|
286 |
|
287 | export interface SequenceExpression extends BaseExpression {
|
288 | type: "SequenceExpression";
|
289 | expressions: Array<Expression>;
|
290 | }
|
291 |
|
292 | export interface UnaryExpression extends BaseExpression {
|
293 | type: "UnaryExpression";
|
294 | operator: UnaryOperator;
|
295 | prefix: true;
|
296 | argument: Expression;
|
297 | }
|
298 |
|
299 | export interface BinaryExpression extends BaseExpression {
|
300 | type: "BinaryExpression";
|
301 | operator: BinaryOperator;
|
302 | left: Expression;
|
303 | right: Expression;
|
304 | }
|
305 |
|
306 | export interface AssignmentExpression extends BaseExpression {
|
307 | type: "AssignmentExpression";
|
308 | operator: AssignmentOperator;
|
309 | left: Pattern | MemberExpression;
|
310 | right: Expression;
|
311 | }
|
312 |
|
313 | export interface UpdateExpression extends BaseExpression {
|
314 | type: "UpdateExpression";
|
315 | operator: UpdateOperator;
|
316 | argument: Expression;
|
317 | prefix: boolean;
|
318 | }
|
319 |
|
320 | export interface LogicalExpression extends BaseExpression {
|
321 | type: "LogicalExpression";
|
322 | operator: LogicalOperator;
|
323 | left: Expression;
|
324 | right: Expression;
|
325 | }
|
326 |
|
327 | export interface ConditionalExpression extends BaseExpression {
|
328 | type: "ConditionalExpression";
|
329 | test: Expression;
|
330 | alternate: Expression;
|
331 | consequent: Expression;
|
332 | }
|
333 |
|
334 | interface BaseCallExpression extends BaseExpression {
|
335 | callee: Expression | Super;
|
336 | arguments: Array<Expression | SpreadElement>;
|
337 | }
|
338 | export type CallExpression = SimpleCallExpression | NewExpression;
|
339 |
|
340 | export interface SimpleCallExpression extends BaseCallExpression {
|
341 | type: "CallExpression";
|
342 | optional: boolean;
|
343 | }
|
344 |
|
345 | export interface NewExpression extends BaseCallExpression {
|
346 | type: "NewExpression";
|
347 | }
|
348 |
|
349 | export interface MemberExpression extends BaseExpression, BasePattern {
|
350 | type: "MemberExpression";
|
351 | object: Expression | Super;
|
352 | property: Expression | PrivateIdentifier;
|
353 | computed: boolean;
|
354 | optional: boolean;
|
355 | }
|
356 |
|
357 | export type Pattern =
|
358 | Identifier | ObjectPattern | ArrayPattern | RestElement |
|
359 | AssignmentPattern | MemberExpression;
|
360 |
|
361 | interface BasePattern extends BaseNode { }
|
362 |
|
363 | export interface SwitchCase extends BaseNode {
|
364 | type: "SwitchCase";
|
365 | test?: Expression | null | undefined;
|
366 | consequent: Array<Statement>;
|
367 | }
|
368 |
|
369 | export interface CatchClause extends BaseNode {
|
370 | type: "CatchClause";
|
371 | param: Pattern | null;
|
372 | body: BlockStatement;
|
373 | }
|
374 |
|
375 | export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
376 | type: "Identifier";
|
377 | name: string;
|
378 | }
|
379 |
|
380 | export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
381 |
|
382 | export interface SimpleLiteral extends BaseNode, BaseExpression {
|
383 | type: "Literal";
|
384 | value: string | boolean | number | null;
|
385 | raw?: string | undefined;
|
386 | }
|
387 |
|
388 | export interface RegExpLiteral extends BaseNode, BaseExpression {
|
389 | type: "Literal";
|
390 | value?: RegExp | null | undefined;
|
391 | regex: {
|
392 | pattern: string;
|
393 | flags: string;
|
394 | };
|
395 | raw?: string | undefined;
|
396 | }
|
397 |
|
398 | export interface BigIntLiteral extends BaseNode, BaseExpression {
|
399 | type: "Literal";
|
400 | value?: bigint | null | undefined;
|
401 | bigint: string;
|
402 | raw?: string | undefined;
|
403 | }
|
404 |
|
405 | export type UnaryOperator =
|
406 | "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
407 |
|
408 | export type BinaryOperator =
|
409 | "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" |
|
410 | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" |
|
411 | "instanceof";
|
412 |
|
413 | export type LogicalOperator = "||" | "&&" | "??";
|
414 |
|
415 | export type AssignmentOperator =
|
416 | "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" |
|
417 | "|=" | "^=" | "&=";
|
418 |
|
419 | export type UpdateOperator = "++" | "--";
|
420 |
|
421 | export interface ForOfStatement extends BaseForXStatement {
|
422 | type: "ForOfStatement";
|
423 | await: boolean;
|
424 | }
|
425 |
|
426 | export interface Super extends BaseNode {
|
427 | type: "Super";
|
428 | }
|
429 |
|
430 | export interface SpreadElement extends BaseNode {
|
431 | type: "SpreadElement";
|
432 | argument: Expression;
|
433 | }
|
434 |
|
435 | export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
436 | type: "ArrowFunctionExpression";
|
437 | expression: boolean;
|
438 | body: BlockStatement | Expression;
|
439 | }
|
440 |
|
441 | export interface YieldExpression extends BaseExpression {
|
442 | type: "YieldExpression";
|
443 | argument?: Expression | null | undefined;
|
444 | delegate: boolean;
|
445 | }
|
446 |
|
447 | export interface TemplateLiteral extends BaseExpression {
|
448 | type: "TemplateLiteral";
|
449 | quasis: Array<TemplateElement>;
|
450 | expressions: Array<Expression>;
|
451 | }
|
452 |
|
453 | export interface TaggedTemplateExpression extends BaseExpression {
|
454 | type: "TaggedTemplateExpression";
|
455 | tag: Expression;
|
456 | quasi: TemplateLiteral;
|
457 | }
|
458 |
|
459 | export interface TemplateElement extends BaseNode {
|
460 | type: "TemplateElement";
|
461 | tail: boolean;
|
462 | value: {
|
463 |
|
464 | cooked?: string | null | undefined;
|
465 | raw: string;
|
466 | };
|
467 | }
|
468 |
|
469 | export interface AssignmentProperty extends Property {
|
470 | value: Pattern;
|
471 | kind: "init";
|
472 | method: boolean;
|
473 | }
|
474 |
|
475 | export interface ObjectPattern extends BasePattern {
|
476 | type: "ObjectPattern";
|
477 | properties: Array<AssignmentProperty | RestElement>;
|
478 | }
|
479 |
|
480 | export interface ArrayPattern extends BasePattern {
|
481 | type: "ArrayPattern";
|
482 | elements: Array<Pattern | null>;
|
483 | }
|
484 |
|
485 | export interface RestElement extends BasePattern {
|
486 | type: "RestElement";
|
487 | argument: Pattern;
|
488 | }
|
489 |
|
490 | export interface AssignmentPattern extends BasePattern {
|
491 | type: "AssignmentPattern";
|
492 | left: Pattern;
|
493 | right: Expression;
|
494 | }
|
495 |
|
496 | export type Class = ClassDeclaration | ClassExpression;
|
497 | interface BaseClass extends BaseNode {
|
498 | superClass?: Expression | null | undefined;
|
499 | body: ClassBody;
|
500 | }
|
501 |
|
502 | export interface ClassBody extends BaseNode {
|
503 | type: "ClassBody";
|
504 | body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
505 | }
|
506 |
|
507 | export interface MethodDefinition extends BaseNode {
|
508 | type: "MethodDefinition";
|
509 | key: Expression | PrivateIdentifier;
|
510 | value: FunctionExpression;
|
511 | kind: "constructor" | "method" | "get" | "set";
|
512 | computed: boolean;
|
513 | static: boolean;
|
514 | }
|
515 |
|
516 | export interface ClassDeclaration extends BaseClass, BaseDeclaration {
|
517 | type: "ClassDeclaration";
|
518 |
|
519 | id: Identifier | null;
|
520 | }
|
521 |
|
522 | export interface ClassExpression extends BaseClass, BaseExpression {
|
523 | type: "ClassExpression";
|
524 | id?: Identifier | null | undefined;
|
525 | }
|
526 |
|
527 | export interface MetaProperty extends BaseExpression {
|
528 | type: "MetaProperty";
|
529 | meta: Identifier;
|
530 | property: Identifier;
|
531 | }
|
532 |
|
533 | export type ModuleDeclaration =
|
534 | ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration |
|
535 | ExportAllDeclaration;
|
536 | interface BaseModuleDeclaration extends BaseNode { }
|
537 |
|
538 | export type ModuleSpecifier =
|
539 | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier |
|
540 | ExportSpecifier;
|
541 | interface BaseModuleSpecifier extends BaseNode {
|
542 | local: Identifier;
|
543 | }
|
544 |
|
545 | export interface ImportDeclaration extends BaseModuleDeclaration {
|
546 | type: "ImportDeclaration";
|
547 | specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
548 | source: Literal;
|
549 | }
|
550 |
|
551 | export interface ImportSpecifier extends BaseModuleSpecifier {
|
552 | type: "ImportSpecifier";
|
553 | imported: Identifier;
|
554 | }
|
555 |
|
556 | export interface ImportExpression extends BaseExpression {
|
557 | type: "ImportExpression";
|
558 | source: Expression;
|
559 | }
|
560 |
|
561 | export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
562 | type: "ImportDefaultSpecifier";
|
563 | }
|
564 |
|
565 | export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
566 | type: "ImportNamespaceSpecifier";
|
567 | }
|
568 |
|
569 | export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
570 | type: "ExportNamedDeclaration";
|
571 | declaration?: Declaration | null | undefined;
|
572 | specifiers: Array<ExportSpecifier>;
|
573 | source?: Literal | null | undefined;
|
574 | }
|
575 |
|
576 | export interface ExportSpecifier extends BaseModuleSpecifier {
|
577 | type: "ExportSpecifier";
|
578 | exported: Identifier;
|
579 | }
|
580 |
|
581 | export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
582 | type: "ExportDefaultDeclaration";
|
583 | declaration: Declaration | Expression;
|
584 | }
|
585 |
|
586 | export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
587 | type: "ExportAllDeclaration";
|
588 | exported: Identifier | null;
|
589 | source: Literal;
|
590 | }
|
591 |
|
592 | export interface AwaitExpression extends BaseExpression {
|
593 | type: "AwaitExpression";
|
594 | argument: Expression;
|
595 | }
|