yuku-parser 0.4.3 → 0.4.5

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 (4) hide show
  1. package/README.md +10 -8
  2. package/index.d.ts +641 -372
  3. package/index.js +3 -3
  4. package/package.json +16 -16
package/index.d.ts CHANGED
@@ -6,53 +6,58 @@ type SourceLang = "js" | "ts" | "jsx" | "tsx" | "dts";
6
6
 
7
7
  /** Options for configuring the parser. */
8
8
  interface ParseOptions {
9
- /**
10
- * Parse as a classic script or an ES module.
11
- * Module mode enables `import`/`export`, `import.meta`, top-level `await`,
12
- * and strict mode.
13
- * @default "module"
14
- */
15
- sourceType?: SourceType;
16
- /**
17
- * Language variant controls which syntax extensions are enabled.
18
- * @default "js"
19
- */
20
- lang?: SourceLang;
21
- /**
22
- * When true, parenthesized expressions are represented as
23
- * `ParenthesizedExpression` nodes in the AST. When false,
24
- * parentheses are stripped and only the inner expression is kept.
25
- * @default false
26
- */
27
- preserveParens?: boolean;
28
- /**
29
- * Run semantic analysis after parsing and include semantic errors
30
- * (e.g. duplicate declarations, invalid `break`/`continue` targets)
31
- * alongside syntax errors. This requires a separate AST pass and may
32
- * affect performance slightly.
33
- * @default false
34
- */
35
- semanticErrors?: boolean;
9
+ /**
10
+ * Parse as a classic script or an ES module.
11
+ * Module mode enables `import`/`export`, `import.meta`, top-level `await`,
12
+ * and strict mode.
13
+ * @default "module"
14
+ */
15
+ sourceType?: SourceType;
16
+ /**
17
+ * Language variant controls which syntax extensions are enabled.
18
+ * @default "js"
19
+ */
20
+ lang?: SourceLang;
21
+ /**
22
+ * When true, parenthesized expressions are represented as
23
+ * `ParenthesizedExpression` nodes in the AST. When false,
24
+ * parentheses are stripped and only the inner expression is kept.
25
+ * @default true
26
+ */
27
+ preserveParens?: boolean;
28
+ /**
29
+ * Allow `return` statements outside of functions, at the top level.
30
+ * @default false
31
+ */
32
+ allowReturnOutsideFunction?: boolean;
33
+ /**
34
+ * Run semantic analysis after parsing and include semantic errors
35
+ * (e.g. duplicate declarations, invalid `break`/`continue` targets)
36
+ * alongside syntax errors. This requires a separate AST pass and may
37
+ * affect performance slightly.
38
+ * @default false
39
+ */
40
+ semanticErrors?: boolean;
36
41
  }
37
42
 
38
43
  /** A source code comment. */
39
44
  interface Comment {
40
- type: "Line" | "Block";
41
- /** Comment text without the delimiters. */
42
- value: string;
43
- /** Byte offset. */
44
- start: number;
45
- /** Byte offset. */
46
- end: number;
45
+ type: "Line" | "Block";
46
+ /** Comment text without the delimiters. */
47
+ value: string;
48
+ /** Byte offset. */
49
+ start: number;
50
+ /** Byte offset. */
51
+ end: number;
47
52
  }
48
53
 
49
54
  /** A labeled source span attached to a {@link Diagnostic}. */
50
55
  interface DiagnosticLabel {
51
- /** Byte offset. */
52
- start: number;
53
- /** Byte offset. */
54
- end: number;
55
- message: string;
56
+ /** Byte offset. */
57
+ start: number;
58
+ /** Byte offset. */
59
+ end: number;
60
+ message: string;
56
61
  }
57
62
 
58
63
  /**
@@ -60,26 +65,26 @@ interface DiagnosticLabel {
60
65
  * The parser is error tolerant: an AST is always produced even when diagnostics exist.
61
66
  */
62
67
  interface Diagnostic {
63
- severity: "error" | "warning" | "hint" | "info";
64
- message: string;
65
- /** Fix suggestion, or `null` if unavailable. */
66
- help: string | null;
67
- /** Byte offset. */
68
- start: number;
69
- /** Byte offset. */
70
- end: number;
71
- /** Additional source spans providing context. */
72
- labels: DiagnosticLabel[];
68
+ severity: "error" | "warning" | "hint" | "info";
69
+ message: string;
70
+ /** Fix suggestion, or `null` if unavailable. */
71
+ help: string | null;
72
+ /** Byte offset. */
73
+ start: number;
74
+ /** Byte offset. */
75
+ end: number;
76
+ /** Additional source spans providing context. */
77
+ labels: DiagnosticLabel[];
73
78
  }
74
79
 
75
80
  /** The result returned by the parser. */
76
81
  interface ParseResult {
77
- /** Root ESTree/TypeScript-ESTree AST node. */
78
- program: Program;
79
- /** All comments in source order. */
80
- comments: Comment[];
81
- /** Syntax diagnostics, and semantic diagnostics when {@link ParseOptions.semanticErrors} is enabled. */
82
- diagnostics: Diagnostic[];
82
+ /** Root ESTree/TypeScript-ESTree AST node. */
83
+ program: Program;
84
+ /** All comments in source order. */
85
+ comments: Comment[];
86
+ /** Syntax diagnostics, and semantic diagnostics when {@link ParseOptions.semanticErrors} is enabled. */
87
+ diagnostics: Diagnostic[];
83
88
  }
84
89
 
85
90
  /**
@@ -90,539 +95,803 @@ export function parse(source: string, options?: ParseOptions): ParseResult;
90
95
  // AST node types
91
96
 
92
97
  interface BaseNode {
93
- start: number;
94
- end: number;
98
+ start: number;
99
+ end: number;
95
100
  }
96
101
 
97
- type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "<<" | ">>" | ">>>" | "in" | "instanceof";
102
+ type BinaryOperator =
103
+ | "=="
104
+ | "!="
105
+ | "==="
106
+ | "!=="
107
+ | "<"
108
+ | "<="
109
+ | ">"
110
+ | ">="
111
+ | "+"
112
+ | "-"
113
+ | "*"
114
+ | "/"
115
+ | "%"
116
+ | "**"
117
+ | "|"
118
+ | "^"
119
+ | "&"
120
+ | "<<"
121
+ | ">>"
122
+ | ">>>"
123
+ | "in"
124
+ | "instanceof";
98
125
  type LogicalOperator = "&&" | "||" | "??";
99
126
  type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
100
127
  type UpdateOperator = "++" | "--";
101
- type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
128
+ type AssignmentOperator =
129
+ | "="
130
+ | "+="
131
+ | "-="
132
+ | "*="
133
+ | "/="
134
+ | "%="
135
+ | "**="
136
+ | "<<="
137
+ | ">>="
138
+ | ">>>="
139
+ | "|="
140
+ | "^="
141
+ | "&="
142
+ | "||="
143
+ | "&&="
144
+ | "??=";
102
145
 
103
146
  interface Identifier extends BaseNode {
104
- type: "Identifier";
105
- name: string;
147
+ type: "Identifier";
148
+ name: string;
106
149
  }
107
150
  interface PrivateIdentifier extends BaseNode {
108
- type: "PrivateIdentifier";
109
- name: string;
151
+ type: "PrivateIdentifier";
152
+ name: string;
110
153
  }
111
154
  interface StringLiteral extends BaseNode {
112
- type: "Literal";
113
- value: string;
114
- raw: string;
155
+ type: "Literal";
156
+ value: string;
157
+ raw: string;
115
158
  }
116
159
  interface NumericLiteral extends BaseNode {
117
- type: "Literal";
118
- value: number | null;
119
- raw: string;
160
+ type: "Literal";
161
+ value: number | null;
162
+ raw: string;
120
163
  }
121
164
  interface BigIntLiteral extends BaseNode {
122
- type: "Literal";
123
- value: bigint;
124
- raw: string;
125
- bigint: string;
165
+ type: "Literal";
166
+ value: bigint;
167
+ raw: string;
168
+ bigint: string;
126
169
  }
127
170
  interface BooleanLiteral extends BaseNode {
128
- type: "Literal";
129
- value: boolean;
130
- raw: string;
171
+ type: "Literal";
172
+ value: boolean;
173
+ raw: string;
131
174
  }
132
175
  interface NullLiteral extends BaseNode {
133
- type: "Literal";
134
- value: null;
135
- raw: "null";
176
+ type: "Literal";
177
+ value: null;
178
+ raw: "null";
136
179
  }
137
180
  interface RegExpLiteral extends BaseNode {
138
- type: "Literal";
139
- value: RegExp | null;
140
- raw: string;
141
- regex: {
142
- pattern: string;
143
- flags: string;
144
- };
145
- }
146
- type Literal = StringLiteral | NumericLiteral | BigIntLiteral | BooleanLiteral | NullLiteral | RegExpLiteral;
181
+ type: "Literal";
182
+ value: RegExp | null;
183
+ raw: string;
184
+ regex: {
185
+ pattern: string;
186
+ flags: string;
187
+ };
188
+ }
189
+ type Literal =
190
+ | StringLiteral
191
+ | NumericLiteral
192
+ | BigIntLiteral
193
+ | BooleanLiteral
194
+ | NullLiteral
195
+ | RegExpLiteral;
147
196
  interface ArrayPattern extends BaseNode {
148
- type: "ArrayPattern";
149
- elements: Array<BindingPattern | RestElement | null>;
197
+ type: "ArrayPattern";
198
+ elements: Array<BindingPattern | RestElement | null>;
150
199
  }
151
200
  interface ObjectPattern extends BaseNode {
152
- type: "ObjectPattern";
153
- properties: Array<Property | RestElement>;
201
+ type: "ObjectPattern";
202
+ properties: Array<Property | RestElement>;
154
203
  }
155
204
  interface AssignmentPattern extends BaseNode {
156
- type: "AssignmentPattern";
157
- left: BindingPattern;
158
- right: Expression;
205
+ type: "AssignmentPattern";
206
+ left: BindingPattern;
207
+ right: Expression;
159
208
  }
160
209
  interface RestElement extends BaseNode {
161
- type: "RestElement";
162
- argument: BindingPattern;
210
+ type: "RestElement";
211
+ argument: BindingPattern;
163
212
  }
164
213
  type BindingPattern = Identifier | ArrayPattern | ObjectPattern | AssignmentPattern;
165
214
  type FunctionParameter = BindingPattern | RestElement;
166
215
  interface Property extends BaseNode {
167
- type: "Property";
168
- kind: "init" | "get" | "set";
169
- key: Expression;
170
- value: Expression | BindingPattern;
171
- method: boolean;
172
- shorthand: boolean;
173
- computed: boolean;
216
+ type: "Property";
217
+ kind: "init" | "get" | "set";
218
+ key: Expression;
219
+ value: Expression | BindingPattern;
220
+ method: boolean;
221
+ shorthand: boolean;
222
+ computed: boolean;
174
223
  }
175
224
  interface SequenceExpression extends BaseNode {
176
- type: "SequenceExpression";
177
- expressions: Expression[];
225
+ type: "SequenceExpression";
226
+ expressions: Expression[];
178
227
  }
179
228
  interface ParenthesizedExpression extends BaseNode {
180
- type: "ParenthesizedExpression";
181
- expression: Expression;
229
+ type: "ParenthesizedExpression";
230
+ expression: Expression;
182
231
  }
183
232
  interface BinaryExpression extends BaseNode {
184
- type: "BinaryExpression";
185
- left: Expression;
186
- operator: BinaryOperator;
187
- right: Expression;
233
+ type: "BinaryExpression";
234
+ left: Expression;
235
+ operator: BinaryOperator;
236
+ right: Expression;
188
237
  }
189
238
  interface LogicalExpression extends BaseNode {
190
- type: "LogicalExpression";
191
- left: Expression;
192
- operator: LogicalOperator;
193
- right: Expression;
239
+ type: "LogicalExpression";
240
+ left: Expression;
241
+ operator: LogicalOperator;
242
+ right: Expression;
194
243
  }
195
244
  interface ConditionalExpression extends BaseNode {
196
- type: "ConditionalExpression";
197
- test: Expression;
198
- consequent: Expression;
199
- alternate: Expression;
245
+ type: "ConditionalExpression";
246
+ test: Expression;
247
+ consequent: Expression;
248
+ alternate: Expression;
200
249
  }
201
250
  interface UnaryExpression extends BaseNode {
202
- type: "UnaryExpression";
203
- operator: UnaryOperator;
204
- prefix: true;
205
- argument: Expression;
251
+ type: "UnaryExpression";
252
+ operator: UnaryOperator;
253
+ prefix: true;
254
+ argument: Expression;
206
255
  }
207
256
  interface UpdateExpression extends BaseNode {
208
- type: "UpdateExpression";
209
- operator: UpdateOperator;
210
- prefix: boolean;
211
- argument: Expression;
257
+ type: "UpdateExpression";
258
+ operator: UpdateOperator;
259
+ prefix: boolean;
260
+ argument: Expression;
212
261
  }
213
262
  interface AssignmentExpression extends BaseNode {
214
- type: "AssignmentExpression";
215
- operator: AssignmentOperator;
216
- left: Expression | BindingPattern;
217
- right: Expression;
263
+ type: "AssignmentExpression";
264
+ operator: AssignmentOperator;
265
+ left: Expression | BindingPattern;
266
+ right: Expression;
218
267
  }
219
268
  interface YieldExpression extends BaseNode {
220
- type: "YieldExpression";
221
- delegate: boolean;
222
- argument: Expression | null;
269
+ type: "YieldExpression";
270
+ delegate: boolean;
271
+ argument: Expression | null;
223
272
  }
224
273
  interface AwaitExpression extends BaseNode {
225
- type: "AwaitExpression";
226
- argument: Expression;
274
+ type: "AwaitExpression";
275
+ argument: Expression;
227
276
  }
228
277
  interface ArrayExpression extends BaseNode {
229
- type: "ArrayExpression";
230
- elements: Array<Expression | SpreadElement | null>;
278
+ type: "ArrayExpression";
279
+ elements: Array<Expression | SpreadElement | null>;
231
280
  }
232
281
  interface ObjectExpression extends BaseNode {
233
- type: "ObjectExpression";
234
- properties: Array<Property | SpreadElement>;
282
+ type: "ObjectExpression";
283
+ properties: Array<Property | SpreadElement>;
235
284
  }
236
285
  interface SpreadElement extends BaseNode {
237
- type: "SpreadElement";
238
- argument: Expression;
286
+ type: "SpreadElement";
287
+ argument: Expression;
239
288
  }
240
289
  interface MemberExpression extends BaseNode {
241
- type: "MemberExpression";
242
- object: Expression | Super;
243
- property: Expression | PrivateIdentifier;
244
- computed: boolean;
245
- optional: boolean;
290
+ type: "MemberExpression";
291
+ object: Expression | Super;
292
+ property: Expression | PrivateIdentifier;
293
+ computed: boolean;
294
+ optional: boolean;
246
295
  }
247
296
  interface CallExpression extends BaseNode {
248
- type: "CallExpression";
249
- callee: Expression | Super;
250
- arguments: Array<Expression | SpreadElement>;
251
- optional: boolean;
297
+ type: "CallExpression";
298
+ callee: Expression | Super;
299
+ arguments: Array<Expression | SpreadElement>;
300
+ optional: boolean;
252
301
  }
253
302
  interface ChainExpression extends BaseNode {
254
- type: "ChainExpression";
255
- expression: CallExpression | MemberExpression;
303
+ type: "ChainExpression";
304
+ expression: CallExpression | MemberExpression;
256
305
  }
257
306
  interface TaggedTemplateExpression extends BaseNode {
258
- type: "TaggedTemplateExpression";
259
- tag: Expression;
260
- quasi: TemplateLiteral;
307
+ type: "TaggedTemplateExpression";
308
+ tag: Expression;
309
+ quasi: TemplateLiteral;
261
310
  }
262
311
  interface NewExpression extends BaseNode {
263
- type: "NewExpression";
264
- callee: Expression;
265
- arguments: Array<Expression | SpreadElement>;
312
+ type: "NewExpression";
313
+ callee: Expression;
314
+ arguments: Array<Expression | SpreadElement>;
266
315
  }
267
316
  interface MetaProperty extends BaseNode {
268
- type: "MetaProperty";
269
- meta: Identifier;
270
- property: Identifier;
317
+ type: "MetaProperty";
318
+ meta: Identifier;
319
+ property: Identifier;
271
320
  }
272
321
  interface ImportExpression extends BaseNode {
273
- type: "ImportExpression";
274
- source: Expression;
275
- options: Expression | null;
276
- phase: "source" | "defer" | null;
322
+ type: "ImportExpression";
323
+ source: Expression;
324
+ options: Expression | null;
325
+ phase: "source" | "defer" | null;
277
326
  }
278
327
  interface TemplateLiteral extends BaseNode {
279
- type: "TemplateLiteral";
280
- quasis: TemplateElement[];
281
- expressions: Expression[];
328
+ type: "TemplateLiteral";
329
+ quasis: TemplateElement[];
330
+ expressions: Expression[];
282
331
  }
283
332
  interface TemplateElement extends BaseNode {
284
- type: "TemplateElement";
285
- value: {
286
- raw: string;
287
- cooked: string | null;
288
- };
289
- tail: boolean;
333
+ type: "TemplateElement";
334
+ value: {
335
+ raw: string;
336
+ cooked: string | null;
337
+ };
338
+ tail: boolean;
290
339
  }
291
340
  interface Super extends BaseNode {
292
- type: "Super";
341
+ type: "Super";
293
342
  }
294
343
  interface ThisExpression extends BaseNode {
295
- type: "ThisExpression";
344
+ type: "ThisExpression";
296
345
  }
297
346
  interface ExpressionStatement extends BaseNode {
298
- type: "ExpressionStatement";
299
- expression: Expression;
300
- directive?: string;
347
+ type: "ExpressionStatement";
348
+ expression: Expression;
349
+ directive?: string;
301
350
  }
302
351
  interface BlockStatement extends BaseNode {
303
- type: "BlockStatement";
304
- body: Statement[];
352
+ type: "BlockStatement";
353
+ body: Statement[];
305
354
  }
306
355
  interface IfStatement extends BaseNode {
307
- type: "IfStatement";
308
- test: Expression;
309
- consequent: Statement;
310
- alternate: Statement | null;
356
+ type: "IfStatement";
357
+ test: Expression;
358
+ consequent: Statement;
359
+ alternate: Statement | null;
311
360
  }
312
361
  interface SwitchStatement extends BaseNode {
313
- type: "SwitchStatement";
314
- discriminant: Expression;
315
- cases: SwitchCase[];
362
+ type: "SwitchStatement";
363
+ discriminant: Expression;
364
+ cases: SwitchCase[];
316
365
  }
317
366
  interface SwitchCase extends BaseNode {
318
- type: "SwitchCase";
319
- test: Expression | null;
320
- consequent: Statement[];
367
+ type: "SwitchCase";
368
+ test: Expression | null;
369
+ consequent: Statement[];
321
370
  }
322
371
  interface ForStatement extends BaseNode {
323
- type: "ForStatement";
324
- init: VariableDeclaration | Expression | null;
325
- test: Expression | null;
326
- update: Expression | null;
327
- body: Statement;
372
+ type: "ForStatement";
373
+ init: VariableDeclaration | Expression | null;
374
+ test: Expression | null;
375
+ update: Expression | null;
376
+ body: Statement;
328
377
  }
329
378
  interface ForInStatement extends BaseNode {
330
- type: "ForInStatement";
331
- left: VariableDeclaration | Expression;
332
- right: Expression;
333
- body: Statement;
379
+ type: "ForInStatement";
380
+ left: VariableDeclaration | Expression;
381
+ right: Expression;
382
+ body: Statement;
334
383
  }
335
384
  interface ForOfStatement extends BaseNode {
336
- type: "ForOfStatement";
337
- left: VariableDeclaration | Expression;
338
- right: Expression;
339
- body: Statement;
340
- await: boolean;
385
+ type: "ForOfStatement";
386
+ left: VariableDeclaration | Expression;
387
+ right: Expression;
388
+ body: Statement;
389
+ await: boolean;
341
390
  }
342
391
  interface WhileStatement extends BaseNode {
343
- type: "WhileStatement";
344
- test: Expression;
345
- body: Statement;
392
+ type: "WhileStatement";
393
+ test: Expression;
394
+ body: Statement;
346
395
  }
347
396
  interface DoWhileStatement extends BaseNode {
348
- type: "DoWhileStatement";
349
- body: Statement;
350
- test: Expression;
397
+ type: "DoWhileStatement";
398
+ body: Statement;
399
+ test: Expression;
351
400
  }
352
401
  interface BreakStatement extends BaseNode {
353
- type: "BreakStatement";
354
- label: Identifier | null;
402
+ type: "BreakStatement";
403
+ label: Identifier | null;
355
404
  }
356
405
  interface ContinueStatement extends BaseNode {
357
- type: "ContinueStatement";
358
- label: Identifier | null;
406
+ type: "ContinueStatement";
407
+ label: Identifier | null;
359
408
  }
360
409
  interface LabeledStatement extends BaseNode {
361
- type: "LabeledStatement";
362
- label: Identifier;
363
- body: Statement;
410
+ type: "LabeledStatement";
411
+ label: Identifier;
412
+ body: Statement;
364
413
  }
365
414
  interface WithStatement extends BaseNode {
366
- type: "WithStatement";
367
- object: Expression;
368
- body: Statement;
415
+ type: "WithStatement";
416
+ object: Expression;
417
+ body: Statement;
369
418
  }
370
419
  interface ReturnStatement extends BaseNode {
371
- type: "ReturnStatement";
372
- argument: Expression | null;
420
+ type: "ReturnStatement";
421
+ argument: Expression | null;
373
422
  }
374
423
  interface ThrowStatement extends BaseNode {
375
- type: "ThrowStatement";
376
- argument: Expression;
424
+ type: "ThrowStatement";
425
+ argument: Expression;
377
426
  }
378
427
  interface TryStatement extends BaseNode {
379
- type: "TryStatement";
380
- block: BlockStatement;
381
- handler: CatchClause | null;
382
- finalizer: BlockStatement | null;
428
+ type: "TryStatement";
429
+ block: BlockStatement;
430
+ handler: CatchClause | null;
431
+ finalizer: BlockStatement | null;
383
432
  }
384
433
  interface CatchClause extends BaseNode {
385
- type: "CatchClause";
386
- param: BindingPattern | null;
387
- body: BlockStatement;
434
+ type: "CatchClause";
435
+ param: BindingPattern | null;
436
+ body: BlockStatement;
388
437
  }
389
438
  interface DebuggerStatement extends BaseNode {
390
- type: "DebuggerStatement";
439
+ type: "DebuggerStatement";
391
440
  }
392
441
  interface EmptyStatement extends BaseNode {
393
- type: "EmptyStatement";
442
+ type: "EmptyStatement";
394
443
  }
395
444
  interface VariableDeclaration extends BaseNode {
396
- type: "VariableDeclaration";
397
- kind: "var" | "let" | "const" | "using" | "await using";
398
- declarations: VariableDeclarator[];
445
+ type: "VariableDeclaration";
446
+ kind: "var" | "let" | "const" | "using" | "await using";
447
+ declarations: VariableDeclarator[];
399
448
  }
400
449
  interface VariableDeclarator extends BaseNode {
401
- type: "VariableDeclarator";
402
- id: BindingPattern;
403
- init: Expression | null;
450
+ type: "VariableDeclarator";
451
+ id: BindingPattern;
452
+ init: Expression | null;
404
453
  }
405
454
  interface FunctionNodeBase extends BaseNode {
406
- id: Identifier | null;
407
- generator: boolean;
408
- async: boolean;
409
- declare?: boolean;
410
- params: FunctionParameter[];
411
- body: BlockStatement | null;
412
- expression: false;
455
+ id: Identifier | null;
456
+ generator: boolean;
457
+ async: boolean;
458
+ declare?: boolean;
459
+ params: FunctionParameter[];
460
+ body: BlockStatement | null;
461
+ expression: false;
413
462
  }
414
463
  interface FunctionDeclaration extends FunctionNodeBase {
415
- type: "FunctionDeclaration";
464
+ type: "FunctionDeclaration";
416
465
  }
417
466
  interface FunctionExpression extends FunctionNodeBase {
418
- type: "FunctionExpression";
467
+ type: "FunctionExpression";
419
468
  }
420
469
  interface TSDeclareFunction extends FunctionNodeBase {
421
- type: "TSDeclareFunction";
470
+ type: "TSDeclareFunction";
422
471
  }
423
472
  interface TSEmptyBodyFunctionExpression extends FunctionNodeBase {
424
- type: "TSEmptyBodyFunctionExpression";
473
+ type: "TSEmptyBodyFunctionExpression";
425
474
  }
426
475
  interface ArrowFunctionExpression extends BaseNode {
427
- type: "ArrowFunctionExpression";
428
- id: null;
429
- generator: false;
430
- async: boolean;
431
- params: FunctionParameter[];
432
- body: BlockStatement | Expression;
433
- expression: boolean;
476
+ type: "ArrowFunctionExpression";
477
+ id: null;
478
+ generator: false;
479
+ async: boolean;
480
+ params: FunctionParameter[];
481
+ body: BlockStatement | Expression;
482
+ expression: boolean;
434
483
  }
435
484
  interface ClassNodeBase extends BaseNode {
436
- decorators: Decorator[];
437
- id: Identifier | null;
438
- superClass: Expression | null;
439
- body: ClassBody;
485
+ decorators: Decorator[];
486
+ id: Identifier | null;
487
+ superClass: Expression | null;
488
+ body: ClassBody;
440
489
  }
441
490
  interface ClassDeclaration extends ClassNodeBase {
442
- type: "ClassDeclaration";
491
+ type: "ClassDeclaration";
443
492
  }
444
493
  interface ClassExpression extends ClassNodeBase {
445
- type: "ClassExpression";
494
+ type: "ClassExpression";
446
495
  }
447
496
  interface ClassBody extends BaseNode {
448
- type: "ClassBody";
449
- body: ClassElement[];
497
+ type: "ClassBody";
498
+ body: ClassElement[];
450
499
  }
451
500
  interface MethodDefinition extends BaseNode {
452
- type: "MethodDefinition";
453
- decorators: Decorator[];
454
- key: Expression | PrivateIdentifier;
455
- value: FunctionExpression | TSEmptyBodyFunctionExpression;
456
- kind: "constructor" | "method" | "get" | "set";
457
- computed: boolean;
458
- static: boolean;
501
+ type: "MethodDefinition";
502
+ decorators: Decorator[];
503
+ key: Expression | PrivateIdentifier;
504
+ value: FunctionExpression | TSEmptyBodyFunctionExpression;
505
+ kind: "constructor" | "method" | "get" | "set";
506
+ computed: boolean;
507
+ static: boolean;
459
508
  }
460
509
  interface PropertyDefinition extends BaseNode {
461
- type: "PropertyDefinition";
462
- decorators: Decorator[];
463
- key: Expression | PrivateIdentifier;
464
- value: Expression | null;
465
- computed: boolean;
466
- static: boolean;
510
+ type: "PropertyDefinition";
511
+ decorators: Decorator[];
512
+ key: Expression | PrivateIdentifier;
513
+ value: Expression | null;
514
+ computed: boolean;
515
+ static: boolean;
467
516
  }
468
517
  interface AccessorProperty extends BaseNode {
469
- type: "AccessorProperty";
470
- decorators: Decorator[];
471
- key: Expression | PrivateIdentifier;
472
- value: Expression | null;
473
- computed: boolean;
474
- static: boolean;
518
+ type: "AccessorProperty";
519
+ decorators: Decorator[];
520
+ key: Expression | PrivateIdentifier;
521
+ value: Expression | null;
522
+ computed: boolean;
523
+ static: boolean;
475
524
  }
476
525
  interface StaticBlock extends BaseNode {
477
- type: "StaticBlock";
478
- body: Statement[];
526
+ type: "StaticBlock";
527
+ body: Statement[];
479
528
  }
480
529
  interface Decorator extends BaseNode {
481
- type: "Decorator";
482
- expression: Expression;
530
+ type: "Decorator";
531
+ expression: Expression;
483
532
  }
484
533
  type ClassElement = MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock;
485
534
  interface ImportDeclaration extends BaseNode {
486
- type: "ImportDeclaration";
487
- specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
488
- source: StringLiteral;
489
- phase: "source" | "defer" | null;
490
- attributes: ImportAttribute[];
535
+ type: "ImportDeclaration";
536
+ specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
537
+ source: StringLiteral;
538
+ phase: "source" | "defer" | null;
539
+ attributes: ImportAttribute[];
491
540
  }
492
541
  interface ImportSpecifier extends BaseNode {
493
- type: "ImportSpecifier";
494
- imported: Identifier | StringLiteral;
495
- local: Identifier;
542
+ type: "ImportSpecifier";
543
+ imported: Identifier | StringLiteral;
544
+ local: Identifier;
496
545
  }
497
546
  interface ImportDefaultSpecifier extends BaseNode {
498
- type: "ImportDefaultSpecifier";
499
- local: Identifier;
547
+ type: "ImportDefaultSpecifier";
548
+ local: Identifier;
500
549
  }
501
550
  interface ImportNamespaceSpecifier extends BaseNode {
502
- type: "ImportNamespaceSpecifier";
503
- local: Identifier;
551
+ type: "ImportNamespaceSpecifier";
552
+ local: Identifier;
504
553
  }
505
554
  interface ImportAttribute extends BaseNode {
506
- type: "ImportAttribute";
507
- key: Identifier | StringLiteral;
508
- value: StringLiteral;
555
+ type: "ImportAttribute";
556
+ key: Identifier | StringLiteral;
557
+ value: StringLiteral;
509
558
  }
510
559
  interface ExportNamedDeclaration extends BaseNode {
511
- type: "ExportNamedDeclaration";
512
- declaration: Declaration | null;
513
- specifiers: ExportSpecifier[];
514
- source: StringLiteral | null;
515
- attributes: ImportAttribute[];
560
+ type: "ExportNamedDeclaration";
561
+ declaration: Declaration | null;
562
+ specifiers: ExportSpecifier[];
563
+ source: StringLiteral | null;
564
+ attributes: ImportAttribute[];
516
565
  }
517
566
  interface ExportDefaultDeclaration extends BaseNode {
518
- type: "ExportDefaultDeclaration";
519
- declaration: Declaration | Expression;
567
+ type: "ExportDefaultDeclaration";
568
+ declaration: Declaration | Expression;
520
569
  }
521
570
  interface ExportAllDeclaration extends BaseNode {
522
- type: "ExportAllDeclaration";
523
- exported: Identifier | StringLiteral | null;
524
- source: StringLiteral;
525
- attributes: ImportAttribute[];
571
+ type: "ExportAllDeclaration";
572
+ exported: Identifier | StringLiteral | null;
573
+ source: StringLiteral;
574
+ attributes: ImportAttribute[];
526
575
  }
527
576
  interface ExportSpecifier extends BaseNode {
528
- type: "ExportSpecifier";
529
- local: Identifier | StringLiteral;
530
- exported: Identifier | StringLiteral;
577
+ type: "ExportSpecifier";
578
+ local: Identifier | StringLiteral;
579
+ exported: Identifier | StringLiteral;
531
580
  }
532
581
  interface TSExportAssignment extends BaseNode {
533
- type: "TSExportAssignment";
534
- expression: Expression;
582
+ type: "TSExportAssignment";
583
+ expression: Expression;
535
584
  }
536
585
  interface TSNamespaceExportDeclaration extends BaseNode {
537
- type: "TSNamespaceExportDeclaration";
538
- id: Identifier;
586
+ type: "TSNamespaceExportDeclaration";
587
+ id: Identifier;
539
588
  }
540
589
  interface JSXElement extends BaseNode {
541
- type: "JSXElement";
542
- openingElement: JSXOpeningElement;
543
- children: JSXChild[];
544
- closingElement: JSXClosingElement | null;
590
+ type: "JSXElement";
591
+ openingElement: JSXOpeningElement;
592
+ children: JSXChild[];
593
+ closingElement: JSXClosingElement | null;
545
594
  }
546
595
  interface JSXOpeningElement extends BaseNode {
547
- type: "JSXOpeningElement";
548
- name: JSXTagName;
549
- attributes: Array<JSXAttribute | JSXSpreadAttribute>;
550
- selfClosing: boolean;
596
+ type: "JSXOpeningElement";
597
+ name: JSXTagName;
598
+ attributes: Array<JSXAttribute | JSXSpreadAttribute>;
599
+ selfClosing: boolean;
551
600
  }
552
601
  interface JSXClosingElement extends BaseNode {
553
- type: "JSXClosingElement";
554
- name: JSXTagName;
602
+ type: "JSXClosingElement";
603
+ name: JSXTagName;
555
604
  }
556
605
  interface JSXFragment extends BaseNode {
557
- type: "JSXFragment";
558
- openingFragment: JSXOpeningFragment;
559
- children: JSXChild[];
560
- closingFragment: JSXClosingFragment;
606
+ type: "JSXFragment";
607
+ openingFragment: JSXOpeningFragment;
608
+ children: JSXChild[];
609
+ closingFragment: JSXClosingFragment;
561
610
  }
562
611
  interface JSXOpeningFragment extends BaseNode {
563
- type: "JSXOpeningFragment";
564
- attributes: [];
565
- selfClosing: false;
612
+ type: "JSXOpeningFragment";
613
+ attributes: [];
614
+ selfClosing: false;
566
615
  }
567
616
  interface JSXClosingFragment extends BaseNode {
568
- type: "JSXClosingFragment";
617
+ type: "JSXClosingFragment";
569
618
  }
570
619
  interface JSXIdentifier extends BaseNode {
571
- type: "JSXIdentifier";
572
- name: string;
620
+ type: "JSXIdentifier";
621
+ name: string;
573
622
  }
574
623
  interface JSXNamespacedName extends BaseNode {
575
- type: "JSXNamespacedName";
576
- namespace: JSXIdentifier;
577
- name: JSXIdentifier;
624
+ type: "JSXNamespacedName";
625
+ namespace: JSXIdentifier;
626
+ name: JSXIdentifier;
578
627
  }
579
628
  interface JSXMemberExpression extends BaseNode {
580
- type: "JSXMemberExpression";
581
- object: JSXIdentifier | JSXMemberExpression;
582
- property: JSXIdentifier;
629
+ type: "JSXMemberExpression";
630
+ object: JSXIdentifier | JSXMemberExpression;
631
+ property: JSXIdentifier;
583
632
  }
584
633
  interface JSXAttribute extends BaseNode {
585
- type: "JSXAttribute";
586
- name: JSXIdentifier | JSXNamespacedName;
587
- value: StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment | null;
634
+ type: "JSXAttribute";
635
+ name: JSXIdentifier | JSXNamespacedName;
636
+ value: StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment | null;
588
637
  }
589
638
  interface JSXSpreadAttribute extends BaseNode {
590
- type: "JSXSpreadAttribute";
591
- argument: Expression;
639
+ type: "JSXSpreadAttribute";
640
+ argument: Expression;
592
641
  }
593
642
  interface JSXExpressionContainer extends BaseNode {
594
- type: "JSXExpressionContainer";
595
- expression: Expression | JSXEmptyExpression;
643
+ type: "JSXExpressionContainer";
644
+ expression: Expression | JSXEmptyExpression;
596
645
  }
597
646
  interface JSXEmptyExpression extends BaseNode {
598
- type: "JSXEmptyExpression";
647
+ type: "JSXEmptyExpression";
599
648
  }
600
649
  interface JSXText extends BaseNode {
601
- type: "JSXText";
602
- value: string;
603
- raw: string;
650
+ type: "JSXText";
651
+ value: string;
652
+ raw: string;
604
653
  }
605
654
  interface JSXSpreadChild extends BaseNode {
606
- type: "JSXSpreadChild";
607
- expression: Expression;
655
+ type: "JSXSpreadChild";
656
+ expression: Expression;
608
657
  }
609
658
  type JSXTagName = JSXIdentifier | JSXNamespacedName | JSXMemberExpression;
610
659
  type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild;
611
660
  interface Program extends BaseNode {
612
- type: "Program";
613
- sourceType: "module" | "script";
614
- hashbang: string | null;
615
- body: Array<Statement | ModuleDeclaration>;
661
+ type: "Program";
662
+ sourceType: "module" | "script";
663
+ hashbang: string | null;
664
+ body: Array<Statement | ModuleDeclaration>;
616
665
  }
617
666
 
618
667
  type Declaration = FunctionDeclaration | ClassDeclaration | VariableDeclaration | TSDeclareFunction;
619
668
 
620
- type Expression = Identifier | Literal | ThisExpression | Super | ArrayExpression | ObjectExpression | FunctionExpression | ArrowFunctionExpression | ClassExpression | TaggedTemplateExpression | TemplateLiteral | MemberExpression | CallExpression | NewExpression | ChainExpression | SequenceExpression | ParenthesizedExpression | BinaryExpression | LogicalExpression | ConditionalExpression | UnaryExpression | UpdateExpression | AssignmentExpression | YieldExpression | AwaitExpression | ImportExpression | MetaProperty | SpreadElement | TSEmptyBodyFunctionExpression | JSXElement | JSXFragment;
669
+ type Expression =
670
+ | Identifier
671
+ | Literal
672
+ | ThisExpression
673
+ | Super
674
+ | ArrayExpression
675
+ | ObjectExpression
676
+ | FunctionExpression
677
+ | ArrowFunctionExpression
678
+ | ClassExpression
679
+ | TaggedTemplateExpression
680
+ | TemplateLiteral
681
+ | MemberExpression
682
+ | CallExpression
683
+ | NewExpression
684
+ | ChainExpression
685
+ | SequenceExpression
686
+ | ParenthesizedExpression
687
+ | BinaryExpression
688
+ | LogicalExpression
689
+ | ConditionalExpression
690
+ | UnaryExpression
691
+ | UpdateExpression
692
+ | AssignmentExpression
693
+ | YieldExpression
694
+ | AwaitExpression
695
+ | ImportExpression
696
+ | MetaProperty
697
+ | SpreadElement
698
+ | TSEmptyBodyFunctionExpression
699
+ | JSXElement
700
+ | JSXFragment;
621
701
 
622
- type Statement = ExpressionStatement | BlockStatement | EmptyStatement | DebuggerStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | WithStatement | Declaration;
702
+ type Statement =
703
+ | ExpressionStatement
704
+ | BlockStatement
705
+ | EmptyStatement
706
+ | DebuggerStatement
707
+ | ReturnStatement
708
+ | LabeledStatement
709
+ | BreakStatement
710
+ | ContinueStatement
711
+ | IfStatement
712
+ | SwitchStatement
713
+ | ThrowStatement
714
+ | TryStatement
715
+ | WhileStatement
716
+ | DoWhileStatement
717
+ | ForStatement
718
+ | ForInStatement
719
+ | ForOfStatement
720
+ | WithStatement
721
+ | Declaration;
623
722
 
624
- type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | TSExportAssignment | TSNamespaceExportDeclaration;
723
+ type ModuleDeclaration =
724
+ | ImportDeclaration
725
+ | ExportNamedDeclaration
726
+ | ExportDefaultDeclaration
727
+ | ExportAllDeclaration
728
+ | TSExportAssignment
729
+ | TSNamespaceExportDeclaration;
625
730
 
626
- type Node = Program | Statement | Expression | ModuleDeclaration | Property | PrivateIdentifier | TemplateElement | VariableDeclarator | CatchClause | SwitchCase | RestElement | ArrayPattern | ObjectPattern | AssignmentPattern | ClassBody | MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock | Decorator | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportAttribute | ExportSpecifier | JSXOpeningElement | JSXClosingElement | JSXOpeningFragment | JSXClosingFragment | JSXIdentifier | JSXNamespacedName | JSXMemberExpression | JSXAttribute | JSXSpreadAttribute | JSXExpressionContainer | JSXEmptyExpression | JSXText | JSXSpreadChild;
731
+ type Node =
732
+ | Program
733
+ | Statement
734
+ | Expression
735
+ | ModuleDeclaration
736
+ | Property
737
+ | PrivateIdentifier
738
+ | TemplateElement
739
+ | VariableDeclarator
740
+ | CatchClause
741
+ | SwitchCase
742
+ | RestElement
743
+ | ArrayPattern
744
+ | ObjectPattern
745
+ | AssignmentPattern
746
+ | ClassBody
747
+ | MethodDefinition
748
+ | PropertyDefinition
749
+ | AccessorProperty
750
+ | StaticBlock
751
+ | Decorator
752
+ | ImportSpecifier
753
+ | ImportDefaultSpecifier
754
+ | ImportNamespaceSpecifier
755
+ | ImportAttribute
756
+ | ExportSpecifier
757
+ | JSXOpeningElement
758
+ | JSXClosingElement
759
+ | JSXOpeningFragment
760
+ | JSXClosingFragment
761
+ | JSXIdentifier
762
+ | JSXNamespacedName
763
+ | JSXMemberExpression
764
+ | JSXAttribute
765
+ | JSXSpreadAttribute
766
+ | JSXExpressionContainer
767
+ | JSXEmptyExpression
768
+ | JSXText
769
+ | JSXSpreadChild;
627
770
 
628
- export type { ParseOptions, ParseResult, Comment, Diagnostic, DiagnosticLabel, SourceType, SourceLang, BaseNode, Program, Statement, Expression, Declaration, ModuleDeclaration, Node, Identifier, PrivateIdentifier, Literal, StringLiteral, NumericLiteral, BigIntLiteral, BooleanLiteral, NullLiteral, RegExpLiteral, BindingPattern, FunctionParameter, Property, ArrayPattern, ObjectPattern, AssignmentPattern, RestElement, SequenceExpression, ParenthesizedExpression, BinaryExpression, LogicalExpression, ConditionalExpression, UnaryExpression, UpdateExpression, AssignmentExpression, YieldExpression, AwaitExpression, ArrayExpression, ObjectExpression, SpreadElement, MemberExpression, CallExpression, ChainExpression, TaggedTemplateExpression, NewExpression, MetaProperty, ImportExpression, TemplateLiteral, TemplateElement, Super, ThisExpression, ExpressionStatement, BlockStatement, IfStatement, SwitchStatement, SwitchCase, ForStatement, ForInStatement, ForOfStatement, WhileStatement, DoWhileStatement, BreakStatement, ContinueStatement, LabeledStatement, WithStatement, ReturnStatement, ThrowStatement, TryStatement, CatchClause, DebuggerStatement, EmptyStatement, VariableDeclaration, VariableDeclarator, FunctionDeclaration, FunctionExpression, TSDeclareFunction, TSEmptyBodyFunctionExpression, ArrowFunctionExpression, ClassDeclaration, ClassExpression, ClassBody, MethodDefinition, PropertyDefinition, AccessorProperty, StaticBlock, Decorator, ClassElement, ImportDeclaration, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportAttribute, ExportNamedDeclaration, ExportDefaultDeclaration, ExportAllDeclaration, ExportSpecifier, TSExportAssignment, TSNamespaceExportDeclaration, JSXElement, JSXOpeningElement, JSXClosingElement, JSXFragment, JSXOpeningFragment, JSXClosingFragment, JSXIdentifier, JSXNamespacedName, JSXMemberExpression, JSXAttribute, JSXSpreadAttribute, JSXExpressionContainer, JSXEmptyExpression, JSXText, JSXSpreadChild, JSXTagName, JSXChild, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, AssignmentOperator, FunctionNodeBase, ClassNodeBase };
771
+ export type {
772
+ ParseOptions,
773
+ ParseResult,
774
+ Comment,
775
+ Diagnostic,
776
+ DiagnosticLabel,
777
+ SourceType,
778
+ SourceLang,
779
+ BaseNode,
780
+ Program,
781
+ Statement,
782
+ Expression,
783
+ Declaration,
784
+ ModuleDeclaration,
785
+ Node,
786
+ Identifier,
787
+ PrivateIdentifier,
788
+ Literal,
789
+ StringLiteral,
790
+ NumericLiteral,
791
+ BigIntLiteral,
792
+ BooleanLiteral,
793
+ NullLiteral,
794
+ RegExpLiteral,
795
+ BindingPattern,
796
+ FunctionParameter,
797
+ Property,
798
+ ArrayPattern,
799
+ ObjectPattern,
800
+ AssignmentPattern,
801
+ RestElement,
802
+ SequenceExpression,
803
+ ParenthesizedExpression,
804
+ BinaryExpression,
805
+ LogicalExpression,
806
+ ConditionalExpression,
807
+ UnaryExpression,
808
+ UpdateExpression,
809
+ AssignmentExpression,
810
+ YieldExpression,
811
+ AwaitExpression,
812
+ ArrayExpression,
813
+ ObjectExpression,
814
+ SpreadElement,
815
+ MemberExpression,
816
+ CallExpression,
817
+ ChainExpression,
818
+ TaggedTemplateExpression,
819
+ NewExpression,
820
+ MetaProperty,
821
+ ImportExpression,
822
+ TemplateLiteral,
823
+ TemplateElement,
824
+ Super,
825
+ ThisExpression,
826
+ ExpressionStatement,
827
+ BlockStatement,
828
+ IfStatement,
829
+ SwitchStatement,
830
+ SwitchCase,
831
+ ForStatement,
832
+ ForInStatement,
833
+ ForOfStatement,
834
+ WhileStatement,
835
+ DoWhileStatement,
836
+ BreakStatement,
837
+ ContinueStatement,
838
+ LabeledStatement,
839
+ WithStatement,
840
+ ReturnStatement,
841
+ ThrowStatement,
842
+ TryStatement,
843
+ CatchClause,
844
+ DebuggerStatement,
845
+ EmptyStatement,
846
+ VariableDeclaration,
847
+ VariableDeclarator,
848
+ FunctionDeclaration,
849
+ FunctionExpression,
850
+ TSDeclareFunction,
851
+ TSEmptyBodyFunctionExpression,
852
+ ArrowFunctionExpression,
853
+ ClassDeclaration,
854
+ ClassExpression,
855
+ ClassBody,
856
+ MethodDefinition,
857
+ PropertyDefinition,
858
+ AccessorProperty,
859
+ StaticBlock,
860
+ Decorator,
861
+ ClassElement,
862
+ ImportDeclaration,
863
+ ImportSpecifier,
864
+ ImportDefaultSpecifier,
865
+ ImportNamespaceSpecifier,
866
+ ImportAttribute,
867
+ ExportNamedDeclaration,
868
+ ExportDefaultDeclaration,
869
+ ExportAllDeclaration,
870
+ ExportSpecifier,
871
+ TSExportAssignment,
872
+ TSNamespaceExportDeclaration,
873
+ JSXElement,
874
+ JSXOpeningElement,
875
+ JSXClosingElement,
876
+ JSXFragment,
877
+ JSXOpeningFragment,
878
+ JSXClosingFragment,
879
+ JSXIdentifier,
880
+ JSXNamespacedName,
881
+ JSXMemberExpression,
882
+ JSXAttribute,
883
+ JSXSpreadAttribute,
884
+ JSXExpressionContainer,
885
+ JSXEmptyExpression,
886
+ JSXText,
887
+ JSXSpreadChild,
888
+ JSXTagName,
889
+ JSXChild,
890
+ BinaryOperator,
891
+ LogicalOperator,
892
+ UnaryOperator,
893
+ UpdateOperator,
894
+ AssignmentOperator,
895
+ FunctionNodeBase,
896
+ ClassNodeBase,
897
+ };