sveast 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -15,15 +15,6 @@ export declare function isValidType(text: string, options?: {
15
15
  inline?: boolean;
16
16
  }): boolean;
17
17
 
18
- /**
19
- * Parses a Svelte component into svelte's modern AST, the same as
20
- * `parse(source, { modern: true })` from svelte/compiler. From svelte's
21
- * `Parser` constructor (`phases/1-parse/index.js`).
22
- *
23
- * Throws a {@link ParseError} on a syntax error.
24
- */
25
- export declare function parse(source: string, options?: ParseOptions): AST.Root;
26
-
27
18
  /**
28
19
  * Options for {@link parse}. The defaults give svelte's own output, minus
29
20
  * `loc` and `name_loc`.
@@ -41,1149 +32,67 @@ export interface ParseOptions {
41
32
  * `comments` are empty and CSS syntax errors aren't reported. Default `true`.
42
33
  */
43
34
  css?: boolean;
35
+ /**
36
+ * Parse each `<script>`'s JavaScript or TypeScript. With `false`, scripts
37
+ * keep their attributes and bounds, and `content` is a `Program` with its
38
+ * `start` and `end` but an empty `body`; their comments aren't in
39
+ * `comments`, and their syntax errors aren't reported. Expressions in the
40
+ * markup are still parsed. Default `true`.
41
+ */
42
+ script?: boolean;
43
+ /**
44
+ * Collect JavaScript comments, in scripts, expressions and tags, into
45
+ * `comments` and attach them to nodes as `leadingComments` and
46
+ * `trailingComments`. With `false`, `comments` is empty and no node has
47
+ * either field, including the HTML comment before a `<script>` that
48
+ * svelte copies into its `content.leadingComments`; HTML comments in the
49
+ * markup and CSS comments are kept. Default `true`.
50
+ */
51
+ comments?: boolean;
44
52
  }
45
53
 
46
- export interface BaseNodeWithoutComments {
47
- type: string;
48
- start: number;
49
- end: number;
50
- loc?: SourceLocation | null | undefined;
51
- range?: [number, number] | undefined;
52
- }
53
-
54
- export interface BaseNode extends BaseNodeWithoutComments {
55
- leadingComments?: Comment[] | undefined;
56
- trailingComments?: Comment[] | undefined;
57
- }
58
-
59
- export interface NodeMap {
60
- AssignmentProperty: AssignmentProperty;
61
- CatchClause: CatchClause;
62
- Class: Class;
63
- ClassBody: ClassBody;
64
- Expression: Expression;
65
- Function: Function;
66
- Identifier: Identifier;
67
- Literal: Literal;
68
- MethodDefinition: MethodDefinition;
69
- ModuleDeclaration: ModuleDeclaration;
70
- ModuleSpecifier: ModuleSpecifier;
71
- Pattern: Pattern;
72
- PrivateIdentifier: PrivateIdentifier;
73
- Program: Program;
74
- Property: Property;
75
- PropertyDefinition: PropertyDefinition;
76
- SpreadElement: SpreadElement;
77
- Statement: Statement;
78
- Super: Super;
79
- SwitchCase: SwitchCase;
80
- TemplateElement: TemplateElement;
81
- VariableDeclarator: VariableDeclarator;
82
- ImportAttribute: ImportAttribute;
83
- TSNode: TSNode;
84
- }
85
-
86
- export type Node = NodeMap[keyof NodeMap];
87
-
88
- export interface Comment extends BaseNodeWithoutComments {
89
- type: "Line" | "Block";
90
- value: string;
91
- }
92
-
93
- export interface SourceLocation {
94
- source?: string | null | undefined;
95
- start: Position;
96
- end: Position;
97
- }
98
-
99
- export interface Position {
100
- /** >= 1 */
101
- line: number;
102
- /** >= 0 */
103
- column: number;
104
- }
105
-
106
- export interface Program extends Omit<BaseNode, "leadingComments"> {
107
- type: "Program";
108
- sourceType: "script" | "module";
109
- body: Array<Directive | Statement | ModuleDeclaration>;
110
- comments?: Comment[] | undefined;
111
- /** In a component's `<script>`, an HTML comment right before the tag becomes `{ type: "Line", value }`, without offsets, as in svelte. */
112
- leadingComments?: Array<Comment | {
113
- type: "Line";
114
- value: string;
115
- }> | undefined;
116
- }
117
-
118
- export interface Directive extends BaseNode {
119
- type: "ExpressionStatement";
120
- expression: Literal;
121
- directive: string;
122
- }
123
-
124
- export interface BaseFunction extends BaseNode, TSFunctionFields {
125
- params: Array<Pattern | TSParameterProperty>;
126
- generator?: boolean | undefined;
127
- async?: boolean | undefined;
128
- body: BlockStatement | Expression;
129
- }
130
-
131
- export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
132
-
133
- export type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
134
-
135
- export interface BaseStatement extends BaseNode {
136
- }
137
-
138
- export interface EmptyStatement extends BaseStatement {
139
- type: "EmptyStatement";
140
- }
141
-
142
- export interface BlockStatement extends BaseStatement {
143
- type: "BlockStatement";
144
- body: Statement[];
145
- innerComments?: Comment[] | undefined;
146
- }
147
-
148
- export interface StaticBlock extends Omit<BlockStatement, "type"> {
149
- type: "StaticBlock";
150
- }
151
-
152
- export interface ExpressionStatement extends BaseStatement {
153
- type: "ExpressionStatement";
154
- expression: Expression;
155
- }
156
-
157
- export interface IfStatement extends BaseStatement {
158
- type: "IfStatement";
159
- test: Expression;
160
- consequent: Statement;
161
- alternate?: Statement | null | undefined;
162
- }
163
-
164
- export interface LabeledStatement extends BaseStatement {
165
- type: "LabeledStatement";
166
- label: Identifier;
167
- body: Statement;
168
- }
169
-
170
- export interface BreakStatement extends BaseStatement {
171
- type: "BreakStatement";
172
- label?: Identifier | null | undefined;
173
- }
174
-
175
- export interface ContinueStatement extends BaseStatement {
176
- type: "ContinueStatement";
177
- label?: Identifier | null | undefined;
178
- }
179
-
180
- export interface WithStatement extends BaseStatement {
181
- type: "WithStatement";
182
- object: Expression;
183
- body: Statement;
184
- }
185
-
186
- export interface SwitchStatement extends BaseStatement {
187
- type: "SwitchStatement";
188
- discriminant: Expression;
189
- cases: SwitchCase[];
190
- }
191
-
192
- export interface ReturnStatement extends BaseStatement {
193
- type: "ReturnStatement";
194
- argument?: Expression | null | undefined;
195
- }
196
-
197
- export interface ThrowStatement extends BaseStatement {
198
- type: "ThrowStatement";
199
- argument: Expression;
200
- }
201
-
202
- export interface TryStatement extends BaseStatement {
203
- type: "TryStatement";
204
- block: BlockStatement;
205
- handler?: CatchClause | null | undefined;
206
- finalizer?: BlockStatement | null | undefined;
207
- }
208
-
209
- export interface WhileStatement extends BaseStatement {
210
- type: "WhileStatement";
211
- test: Expression;
212
- body: Statement;
213
- }
214
-
215
- export interface DoWhileStatement extends BaseStatement {
216
- type: "DoWhileStatement";
217
- body: Statement;
218
- test: Expression;
219
- }
220
-
221
- export interface ForStatement extends BaseStatement {
222
- type: "ForStatement";
223
- init?: VariableDeclaration | Expression | null | undefined;
224
- test?: Expression | null | undefined;
225
- update?: Expression | null | undefined;
226
- body: Statement;
227
- }
228
-
229
- export interface BaseForXStatement extends BaseStatement {
230
- left: VariableDeclaration | Pattern;
231
- right: Expression;
232
- body: Statement;
233
- }
234
-
235
- export interface ForInStatement extends BaseForXStatement {
236
- type: "ForInStatement";
237
- }
238
-
239
- export interface DebuggerStatement extends BaseStatement {
240
- type: "DebuggerStatement";
241
- }
242
-
243
- export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | TSDeclaration;
244
-
245
- export interface BaseDeclaration extends BaseStatement {
54
+ /** Options for {@link parseModule}. */
55
+ export interface ParseModuleOptions {
56
+ /** Parse TypeScript. Default `false`. */
57
+ typescript?: boolean;
58
+ /** Add `loc` (line/column) to every node. Default `false`. */
59
+ loc?: boolean;
60
+ /**
61
+ * Attach comments as `leadingComments`/`trailingComments`. With
62
+ * `false`, no node has either field. Default `true`.
63
+ */
64
+ comments?: boolean;
246
65
  }
247
66
 
248
- export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
249
- type: "FunctionDeclaration";
250
- /** It is null when a function declaration is a part of the `export default function` statement */
251
- id: Identifier | null;
252
- body: BlockStatement;
253
- expression: false;
254
- /** No `TSParameterProperty`: `private x` only parses in a class constructor, a `FunctionExpression`. */
255
- params: Pattern[];
67
+ /** Options for {@link parseImportsExports}. */
68
+ export interface ParseImportsExportsOptions {
69
+ /**
70
+ * Parse TypeScript, e.g. `import type`, `export type` and
71
+ * `import a = require("a")`. Default `false`.
72
+ */
73
+ typescript?: boolean;
74
+ /**
75
+ * Return the `export` statements that export the module's own bindings,
76
+ * such as `export let a`, `export function b() {}`, `export { c }` and
77
+ * `export default d`. With `false`, only imports and the exports that
78
+ * have a `from`, such as `export * from "e"` and `export { f } from "f"`,
79
+ * are returned, and the rest is skipped like other code, which is faster
80
+ * when most statements are exported, as in a component's props.
81
+ * Default `true`.
82
+ */
83
+ localExports?: boolean;
256
84
  }
257
85
 
258
- export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
259
- id: Identifier;
260
- }
86
+ /**
87
+ * Parses a Svelte component into svelte's modern AST, the same as
88
+ * `parse(source, { modern: true })` from svelte/compiler. From svelte's
89
+ * `Parser` constructor (`phases/1-parse/index.js`).
90
+ *
91
+ * Throws a {@link ParseError} on a syntax error.
92
+ */
93
+ export declare function parse(source: string, options?: ParseOptions): AST.Root;
261
94
 
262
- export interface VariableDeclaration extends BaseDeclaration {
263
- type: "VariableDeclaration";
264
- declarations: VariableDeclarator[];
265
- kind: "var" | "let" | "const" | "using" | "await using";
266
- declare?: boolean;
267
- }
268
-
269
- export interface VariableDeclarator extends BaseNode {
270
- type: "VariableDeclarator";
271
- id: Pattern;
272
- init?: Expression | null | undefined;
273
- definite?: boolean;
274
- }
275
-
276
- export interface ExpressionMap {
277
- ArrayExpression: ArrayExpression;
278
- ArrowFunctionExpression: ArrowFunctionExpression;
279
- AssignmentExpression: AssignmentExpression;
280
- AwaitExpression: AwaitExpression;
281
- BinaryExpression: BinaryExpression;
282
- CallExpression: CallExpression;
283
- ChainExpression: ChainExpression;
284
- ClassExpression: ClassExpression;
285
- ConditionalExpression: ConditionalExpression;
286
- FunctionExpression: FunctionExpression;
287
- Identifier: Identifier;
288
- ImportExpression: ImportExpression;
289
- Literal: Literal;
290
- LogicalExpression: LogicalExpression;
291
- MemberExpression: MemberExpression;
292
- MetaProperty: MetaProperty;
293
- NewExpression: NewExpression;
294
- ObjectExpression: ObjectExpression;
295
- SequenceExpression: SequenceExpression;
296
- TaggedTemplateExpression: TaggedTemplateExpression;
297
- TemplateLiteral: TemplateLiteral;
298
- ThisExpression: ThisExpression;
299
- UnaryExpression: UnaryExpression;
300
- UpdateExpression: UpdateExpression;
301
- YieldExpression: YieldExpression;
302
- TSExpression: TSExpression;
303
- }
304
-
305
- export type Expression = ExpressionMap[keyof ExpressionMap];
306
-
307
- export interface BaseExpression extends BaseNode {
308
- }
309
-
310
- export type ChainElement = SimpleCallExpression | MemberExpression;
311
-
312
- export interface ChainExpression extends BaseExpression {
313
- type: "ChainExpression";
314
- expression: ChainElement;
315
- }
316
-
317
- export interface ThisExpression extends BaseExpression {
318
- type: "ThisExpression";
319
- }
320
-
321
- export interface ArrayExpression extends BaseExpression {
322
- type: "ArrayExpression";
323
- elements: Array<Expression | SpreadElement | null>;
324
- }
325
-
326
- export interface ObjectExpression extends BaseExpression {
327
- type: "ObjectExpression";
328
- properties: Array<Property | SpreadElement>;
329
- }
330
-
331
- export interface PrivateIdentifier extends BaseNode {
332
- type: "PrivateIdentifier";
333
- name: string;
334
- }
335
-
336
- export interface Property extends BaseNode {
337
- type: "Property";
338
- key: Expression;
339
- value: Expression | Pattern;
340
- kind: "init" | "get" | "set";
341
- method: boolean;
342
- shorthand: boolean;
343
- computed: boolean;
344
- decorators?: Decorator[];
345
- }
346
-
347
- export interface PropertyDefinition extends BaseNode, TSClassMemberFields {
348
- type: "PropertyDefinition";
349
- key: Expression | PrivateIdentifier;
350
- value?: Expression | null | undefined;
351
- computed: boolean;
352
- static: boolean;
353
- typeAnnotation?: TSTypeAnnotation;
354
- definite?: boolean;
355
- }
356
-
357
- export interface FunctionExpression extends BaseFunction, BaseExpression {
358
- id?: Identifier | null | undefined;
359
- type: "FunctionExpression";
360
- body: BlockStatement;
361
- expression: false;
362
- }
363
-
364
- export interface SequenceExpression extends BaseExpression {
365
- type: "SequenceExpression";
366
- expressions: Expression[];
367
- }
368
-
369
- export interface UnaryExpression extends BaseExpression {
370
- type: "UnaryExpression";
371
- operator: UnaryOperator;
372
- prefix: true;
373
- argument: Expression;
374
- }
375
-
376
- export interface BinaryExpression extends BaseExpression {
377
- type: "BinaryExpression";
378
- operator: BinaryOperator;
379
- left: Expression | PrivateIdentifier;
380
- right: Expression;
381
- }
382
-
383
- export interface AssignmentExpression extends BaseExpression {
384
- type: "AssignmentExpression";
385
- operator: AssignmentOperator;
386
- left: Pattern | MemberExpression | TSAsExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
387
- right: Expression;
388
- }
389
-
390
- export interface UpdateExpression extends BaseExpression {
391
- type: "UpdateExpression";
392
- operator: UpdateOperator;
393
- argument: Expression;
394
- prefix: boolean;
395
- }
396
-
397
- export interface LogicalExpression extends BaseExpression {
398
- type: "LogicalExpression";
399
- operator: LogicalOperator;
400
- left: Expression;
401
- right: Expression;
402
- }
403
-
404
- export interface ConditionalExpression extends BaseExpression {
405
- type: "ConditionalExpression";
406
- test: Expression;
407
- alternate: Expression;
408
- consequent: Expression;
409
- }
410
-
411
- export interface BaseCallExpression extends BaseExpression {
412
- callee: Expression | Super;
413
- arguments: Array<Expression | SpreadElement>;
414
- typeArguments?: TSTypeParameterInstantiation;
415
- }
416
-
417
- export type CallExpression = SimpleCallExpression | NewExpression;
418
-
419
- export interface SimpleCallExpression extends BaseCallExpression {
420
- type: "CallExpression";
421
- /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
422
- optional?: boolean;
423
- }
424
-
425
- export interface NewExpression extends BaseCallExpression {
426
- type: "NewExpression";
427
- }
428
-
429
- export interface MemberExpression extends BaseExpression, BasePattern {
430
- type: "MemberExpression";
431
- object: Expression | Super;
432
- property: Expression | PrivateIdentifier;
433
- computed: boolean;
434
- /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
435
- optional?: boolean;
436
- }
437
-
438
- export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
439
-
440
- export interface BasePattern extends BaseNode {
441
- }
442
-
443
- export interface SwitchCase extends BaseNode {
444
- type: "SwitchCase";
445
- test?: Expression | null | undefined;
446
- consequent: Statement[];
447
- }
448
-
449
- export interface CatchClause extends BaseNode {
450
- type: "CatchClause";
451
- param: Pattern | null;
452
- body: BlockStatement;
453
- }
454
-
455
- export interface Identifier extends BaseNode, BaseExpression, BasePattern, TSBindingFields {
456
- type: "Identifier";
457
- name: string;
458
- }
459
-
460
- export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
461
-
462
- export interface SimpleLiteral extends BaseNode, BaseExpression {
463
- type: "Literal";
464
- value: string | boolean | number | null;
465
- raw?: string | undefined;
466
- }
467
-
468
- /** A string `Literal`: a module specifier, an import attribute, or a quoted module export name. */
469
- export interface StringLiteral extends SimpleLiteral {
470
- value: string;
471
- }
472
-
473
- export interface RegExpLiteral extends BaseNode, BaseExpression {
474
- type: "Literal";
475
- value?: RegExp | null | undefined;
476
- regex: {
477
- pattern: string;
478
- flags: string;
479
- };
480
- raw?: string | undefined;
481
- }
482
-
483
- export interface BigIntLiteral extends BaseNode, BaseExpression {
484
- type: "Literal";
485
- value?: bigint | null | undefined;
486
- bigint: string;
487
- raw?: string | undefined;
488
- }
489
-
490
- export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
491
-
492
- export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
493
-
494
- export type LogicalOperator = "||" | "&&" | "??";
495
-
496
- export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
497
-
498
- export type UpdateOperator = "++" | "--";
499
-
500
- export interface ForOfStatement extends BaseForXStatement {
501
- type: "ForOfStatement";
502
- await: boolean;
503
- }
504
-
505
- export interface Super extends BaseNode {
506
- type: "Super";
507
- }
508
-
509
- export interface SpreadElement extends BaseNode {
510
- type: "SpreadElement";
511
- argument: Expression;
512
- }
513
-
514
- export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
515
- type: "ArrowFunctionExpression";
516
- expression: boolean;
517
- body: BlockStatement | Expression;
518
- id: null;
519
- /** No `TSParameterProperty`: `private x` only parses in a class constructor, a `FunctionExpression`. */
520
- params: Pattern[];
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
- typeArguments?: TSTypeParameterInstantiation;
540
- }
541
-
542
- export interface TemplateElement extends BaseNode {
543
- type: "TemplateElement";
544
- tail: boolean;
545
- value: {
546
- /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
547
- cooked?: string | null | undefined;
548
- raw: string;
549
- };
550
- }
551
-
552
- export interface AssignmentProperty extends Property {
553
- value: Pattern;
554
- kind: "init";
555
- method: boolean;
556
- }
557
-
558
- export interface ObjectPattern extends BasePattern, TSBindingFields {
559
- type: "ObjectPattern";
560
- properties: Array<AssignmentProperty | RestElement>;
561
- }
562
-
563
- export interface ArrayPattern extends BasePattern, TSBindingFields {
564
- type: "ArrayPattern";
565
- elements: Array<Pattern | null>;
566
- }
567
-
568
- export interface RestElement extends BasePattern, TSBindingFields {
569
- type: "RestElement";
570
- argument: Pattern;
571
- }
572
-
573
- export interface AssignmentPattern extends BasePattern {
574
- type: "AssignmentPattern";
575
- left: Pattern;
576
- right: Expression;
577
- decorators?: Decorator[];
578
- }
579
-
580
- export type Class = ClassDeclaration | ClassExpression;
581
-
582
- export interface BaseClass extends BaseNode, TSClassFields {
583
- superClass?: Expression | null | undefined;
584
- body: ClassBody;
585
- }
586
-
587
- export interface ClassBody extends BaseNode {
588
- type: "ClassBody";
589
- body: Array<MethodDefinition | PropertyDefinition | StaticBlock | TSIndexSignature>;
590
- }
591
-
592
- export interface MethodDefinition extends BaseNode, TSClassMemberFields {
593
- type: "MethodDefinition";
594
- key: Expression | PrivateIdentifier;
595
- value: FunctionExpression | TSDeclareMethod;
596
- kind: "constructor" | "method" | "get" | "set";
597
- computed: boolean;
598
- static: boolean;
599
- typeParameters?: TSTypeParameterDeclaration;
600
- }
601
-
602
- export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
603
- type: "ClassDeclaration";
604
- /** It is null when a class declaration is a part of the `export default class` statement */
605
- id: Identifier | null;
606
- }
607
-
608
- export interface ClassDeclaration extends MaybeNamedClassDeclaration {
609
- id: Identifier;
610
- }
611
-
612
- export interface ClassExpression extends BaseClass, BaseExpression {
613
- type: "ClassExpression";
614
- id?: Identifier | null | undefined;
615
- }
616
-
617
- export interface MetaProperty extends BaseExpression {
618
- type: "MetaProperty";
619
- meta: Identifier;
620
- property: Identifier;
621
- }
622
-
623
- export type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | TSModuleDeclarationStatement;
624
-
625
- export interface BaseModuleDeclaration extends BaseNode {
626
- }
627
-
628
- export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
629
-
630
- export interface BaseModuleSpecifier extends BaseNode {
631
- local: Identifier;
632
- }
633
-
634
- export interface ImportDeclaration extends BaseModuleDeclaration {
635
- type: "ImportDeclaration";
636
- specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
637
- /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
638
- attributes?: ImportAttribute[] | undefined;
639
- source: StringLiteral;
640
- importKind?: "type" | "value";
641
- }
642
-
643
- export interface ImportSpecifier extends BaseModuleSpecifier {
644
- type: "ImportSpecifier";
645
- imported: Identifier | StringLiteral;
646
- importKind?: "type" | "value";
647
- }
648
-
649
- export interface ImportAttribute extends BaseNode {
650
- type: "ImportAttribute";
651
- key: Identifier | StringLiteral;
652
- value: StringLiteral;
653
- }
654
-
655
- export interface ImportExpression extends BaseExpression {
656
- type: "ImportExpression";
657
- source: Expression;
658
- options?: Expression | null | undefined;
659
- /** The import attributes, with `typescript: true`; `options` otherwise. */
660
- arguments?: Expression[];
661
- }
662
-
663
- export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
664
- type: "ImportDefaultSpecifier";
665
- }
666
-
667
- export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
668
- type: "ImportNamespaceSpecifier";
669
- }
670
-
671
- export interface ExportNamedDeclaration extends BaseModuleDeclaration {
672
- type: "ExportNamedDeclaration";
673
- declaration?: Declaration | null | undefined;
674
- specifiers: ExportSpecifier[];
675
- /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
676
- attributes?: ImportAttribute[] | undefined;
677
- source?: StringLiteral | null | undefined;
678
- exportKind?: "type" | "value";
679
- }
680
-
681
- export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
682
- type: "ExportSpecifier";
683
- local: Identifier | StringLiteral;
684
- exported: Identifier | StringLiteral;
685
- exportKind?: "type" | "value";
686
- }
687
-
688
- export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
689
- type: "ExportDefaultDeclaration";
690
- declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression | TSDeclareFunction | TSInterfaceDeclaration;
691
- exportKind?: "type" | "value";
692
- }
693
-
694
- export interface ExportAllDeclaration extends BaseModuleDeclaration {
695
- type: "ExportAllDeclaration";
696
- exported: Identifier | StringLiteral | null;
697
- /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
698
- attributes?: ImportAttribute[] | undefined;
699
- source: StringLiteral;
700
- exportKind?: "type" | "value";
701
- }
702
-
703
- export interface AwaitExpression extends BaseExpression {
704
- type: "AwaitExpression";
705
- argument: Expression;
706
- }
707
-
708
- export type TSNode = Decorator | TSTypeAnnotation | TypeNode | TSTypePredicate | TSNamedTupleMember | TSOptionalType | TSRestType | TemplateLiteralType | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSQualifiedName | TypeElement | TSInterfaceBody | TSExpressionWithTypeArguments | TSEnumMember | TSModuleBlock | TSExternalModuleReference | TSParameterProperty | TSDeclareMethod | TSDeclaration | TSModuleDeclarationStatement | TSExpression;
709
-
710
- /** Declarations; in estree's `Declaration` union. */
711
- export type TSDeclaration = TSDeclareFunction | TSEnumDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSTypeAliasDeclaration;
712
-
713
- /** Module-level statements; in estree's `ModuleDeclaration` union. */
714
- export type TSModuleDeclarationStatement = TSExportAssignment | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
715
-
716
- /** Expressions; in estree's `Expression` union. */
717
- export type TSExpression = TSAsExpression | TSInstantiationExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
718
-
719
- export type TypeNode = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSParenthesizedType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperator | TSTypeQuery | TSTypeReference | TSUnionType;
720
-
721
- export type TypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature | TSMethodSignature | TSPropertySignature;
722
-
723
- export type EntityName = Identifier | TSQualifiedName;
724
-
725
- export type Accessibility = "public" | "private" | "protected";
726
-
727
- /** A parameter of a function type, method signature or declared function. */
728
- export type SignatureParameter = Identifier | ObjectPattern | ArrayPattern | RestElement;
729
-
730
- /** Fields the plugin adds to `Identifier`, `ObjectPattern`, `ArrayPattern` and `RestElement`. */
731
- export interface TSBindingFields {
732
- typeAnnotation?: TSTypeAnnotation | undefined;
733
- /** `a?` in a parameter list. */
734
- optional?: boolean;
735
- decorators?: Decorator[];
736
- }
737
-
738
- /** Fields the plugin adds to functions. */
739
- export interface TSFunctionFields {
740
- typeParameters?: TSTypeParameterDeclaration;
741
- returnType?: TSTypeAnnotation;
742
- }
743
-
744
- /** Fields the plugin adds to classes. */
745
- export interface TSClassFields {
746
- typeParameters?: TSTypeParameterDeclaration;
747
- superTypeParameters?: TSTypeParameterInstantiation;
748
- implements?: TSExpressionWithTypeArguments[];
749
- abstract?: boolean;
750
- declare?: boolean;
751
- decorators?: Decorator[];
752
- }
753
-
754
- /** Modifiers the plugin adds to class members. */
755
- export interface TSClassMemberFields {
756
- accessibility?: Accessibility;
757
- abstract?: boolean;
758
- override?: boolean;
759
- readonly?: boolean;
760
- declare?: boolean;
761
- accessor?: boolean;
762
- optional?: boolean;
763
- decorators?: Decorator[];
764
- }
765
-
766
- export interface Decorator extends BaseNode {
767
- type: "Decorator";
768
- expression: Expression;
769
- }
770
-
771
- export interface TSTypeAnnotation extends BaseNode {
772
- type: "TSTypeAnnotation";
773
- /** A predicate (`x is T`, `asserts x`) only in a return type. */
774
- typeAnnotation: TypeNode | TSTypePredicate;
775
- }
776
-
777
- export interface TSTypePredicate extends BaseNode {
778
- type: "TSTypePredicate";
779
- parameterName: Identifier | TSThisType;
780
- asserts: boolean;
781
- /** `null` for `asserts x` without `is`. */
782
- typeAnnotation: TSTypeAnnotation | null;
783
- }
784
-
785
- export interface TSAnyKeyword extends BaseNode {
786
- type: "TSAnyKeyword";
787
- }
788
-
789
- export interface TSBigIntKeyword extends BaseNode {
790
- type: "TSBigIntKeyword";
791
- }
792
-
793
- export interface TSBooleanKeyword extends BaseNode {
794
- type: "TSBooleanKeyword";
795
- }
796
-
797
- export interface TSNeverKeyword extends BaseNode {
798
- type: "TSNeverKeyword";
799
- }
800
-
801
- export interface TSNullKeyword extends BaseNode {
802
- type: "TSNullKeyword";
803
- }
804
-
805
- export interface TSNumberKeyword extends BaseNode {
806
- type: "TSNumberKeyword";
807
- }
808
-
809
- export interface TSObjectKeyword extends BaseNode {
810
- type: "TSObjectKeyword";
811
- }
812
-
813
- export interface TSStringKeyword extends BaseNode {
814
- type: "TSStringKeyword";
815
- }
816
-
817
- export interface TSSymbolKeyword extends BaseNode {
818
- type: "TSSymbolKeyword";
819
- }
820
-
821
- export interface TSUndefinedKeyword extends BaseNode {
822
- type: "TSUndefinedKeyword";
823
- }
824
-
825
- export interface TSUnknownKeyword extends BaseNode {
826
- type: "TSUnknownKeyword";
827
- }
828
-
829
- export interface TSVoidKeyword extends BaseNode {
830
- type: "TSVoidKeyword";
831
- }
832
-
833
- export interface TSThisType extends BaseNode {
834
- type: "TSThisType";
835
- }
836
-
837
- export interface TSArrayType extends BaseNode {
838
- type: "TSArrayType";
839
- elementType: TypeNode;
840
- }
841
-
842
- export interface TSConditionalType extends BaseNode {
843
- type: "TSConditionalType";
844
- checkType: TypeNode;
845
- extendsType: TypeNode;
846
- trueType: TypeNode;
847
- falseType: TypeNode;
848
- }
849
-
850
- export interface TSFunctionType extends BaseNode {
851
- type: "TSFunctionType";
852
- typeParameters?: TSTypeParameterDeclaration;
853
- parameters: SignatureParameter[];
854
- typeAnnotation: TSTypeAnnotation;
855
- }
856
-
857
- export interface TSConstructorType extends BaseNode {
858
- type: "TSConstructorType";
859
- abstract: boolean;
860
- typeParameters?: TSTypeParameterDeclaration;
861
- parameters: SignatureParameter[];
862
- typeAnnotation: TSTypeAnnotation;
863
- }
864
-
865
- export interface TSImportType extends BaseNode {
866
- type: "TSImportType";
867
- argument: StringLiteral;
868
- qualifier?: EntityName;
869
- typeArguments?: TSTypeParameterInstantiation;
870
- }
871
-
872
- export interface TSIndexedAccessType extends BaseNode {
873
- type: "TSIndexedAccessType";
874
- objectType: TypeNode;
875
- indexType: TypeNode;
876
- }
877
-
878
- export interface TSInferType extends BaseNode {
879
- type: "TSInferType";
880
- typeParameter: TSTypeParameter;
881
- }
882
-
883
- export interface TSIntersectionType extends BaseNode {
884
- type: "TSIntersectionType";
885
- types: TypeNode[];
886
- }
887
-
888
- export interface TSUnionType extends BaseNode {
889
- type: "TSUnionType";
890
- types: TypeNode[];
891
- }
892
-
893
- export interface TSLiteralType extends BaseNode {
894
- type: "TSLiteralType";
895
- /** `UnaryExpression` for a negative number, e.g. `-1`. */
896
- literal: Literal | UnaryExpression | TemplateLiteralType;
897
- }
898
-
899
- /** A template literal type, `` `prefix-${T}` ``: a `TemplateLiteral` whose expressions are types. */
900
- export interface TemplateLiteralType extends BaseNode {
901
- type: "TemplateLiteral";
902
- quasis: TemplateElement[];
903
- expressions: TypeNode[];
904
- }
905
-
906
- export interface TSMappedType extends BaseNode {
907
- type: "TSMappedType";
908
- readonly?: true | "+" | "-";
909
- typeParameter: TSTypeParameter;
910
- /** The `as` clause. */
911
- nameType: TypeNode | null;
912
- optional?: true | "+" | "-";
913
- typeAnnotation?: TypeNode;
914
- }
915
-
916
- export interface TSParenthesizedType extends BaseNode {
917
- type: "TSParenthesizedType";
918
- typeAnnotation: TypeNode;
919
- }
920
-
921
- export interface TSTupleType extends BaseNode {
922
- type: "TSTupleType";
923
- elementTypes: Array<TypeNode | TSNamedTupleMember | TSOptionalType | TSRestType>;
924
- }
925
-
926
- export interface TSNamedTupleMember extends BaseNode {
927
- type: "TSNamedTupleMember";
928
- label: Identifier;
929
- optional: boolean;
930
- elementType: TypeNode;
931
- }
932
-
933
- export interface TSOptionalType extends BaseNode {
934
- type: "TSOptionalType";
935
- typeAnnotation: TypeNode;
936
- }
937
-
938
- export interface TSRestType extends BaseNode {
939
- type: "TSRestType";
940
- typeAnnotation: TypeNode | TSNamedTupleMember;
941
- }
942
-
943
- export interface TSTypeLiteral extends BaseNode {
944
- type: "TSTypeLiteral";
945
- members: TypeElement[];
946
- }
947
-
948
- export interface TSTypeOperator extends BaseNode {
949
- type: "TSTypeOperator";
950
- operator: "keyof" | "unique" | "readonly";
951
- typeAnnotation: TypeNode;
952
- }
953
-
954
- export interface TSTypeQuery extends BaseNode {
955
- type: "TSTypeQuery";
956
- exprName: EntityName | TSImportType;
957
- typeArguments?: TSTypeParameterInstantiation;
958
- }
959
-
960
- export interface TSTypeReference extends BaseNode {
961
- type: "TSTypeReference";
962
- typeName: EntityName;
963
- typeArguments?: TSTypeParameterInstantiation;
964
- }
965
-
966
- export interface TSQualifiedName extends BaseNode {
967
- type: "TSQualifiedName";
968
- left: EntityName;
969
- right: Identifier;
970
- }
971
-
972
- export interface TSTypeParameterDeclaration extends BaseNode {
973
- type: "TSTypeParameterDeclaration";
974
- params: TSTypeParameter[];
975
- /** With a trailing comma, its offset. */
976
- extra?: {
977
- trailingComma: number;
978
- };
979
- }
980
-
981
- export interface TSTypeParameter extends BaseNode {
982
- type: "TSTypeParameter";
983
- name: string;
984
- constraint?: TypeNode;
985
- default?: TypeNode;
986
- const?: true;
987
- in?: true;
988
- out?: true;
989
- }
990
-
991
- export interface TSTypeParameterInstantiation extends BaseNode {
992
- type: "TSTypeParameterInstantiation";
993
- params: TypeNode[];
994
- }
995
-
996
- export interface TSPropertySignature extends BaseNode {
997
- type: "TSPropertySignature";
998
- key: Expression;
999
- computed?: boolean;
1000
- optional?: boolean;
1001
- readonly?: boolean;
1002
- typeAnnotation?: TSTypeAnnotation;
1003
- }
1004
-
1005
- export interface TSMethodSignature extends BaseNode {
1006
- type: "TSMethodSignature";
1007
- key: Expression;
1008
- computed?: boolean;
1009
- optional?: boolean;
1010
- kind: "method" | "get" | "set";
1011
- typeParameters?: TSTypeParameterDeclaration;
1012
- parameters: SignatureParameter[];
1013
- /** The return type. */
1014
- typeAnnotation?: TSTypeAnnotation;
1015
- }
1016
-
1017
- /** In an interface, a type literal, or a class body (with the class member modifiers). */
1018
- export interface TSIndexSignature extends BaseNode, TSClassMemberFields {
1019
- type: "TSIndexSignature";
1020
- parameters: Identifier[];
1021
- typeAnnotation?: TSTypeAnnotation;
1022
- static?: boolean;
1023
- }
1024
-
1025
- export interface TSCallSignatureDeclaration extends BaseNode {
1026
- type: "TSCallSignatureDeclaration";
1027
- typeParameters?: TSTypeParameterDeclaration;
1028
- parameters: SignatureParameter[];
1029
- typeAnnotation?: TSTypeAnnotation;
1030
- }
1031
-
1032
- export interface TSConstructSignatureDeclaration extends BaseNode {
1033
- type: "TSConstructSignatureDeclaration";
1034
- typeParameters?: TSTypeParameterDeclaration;
1035
- parameters: SignatureParameter[];
1036
- typeAnnotation?: TSTypeAnnotation;
1037
- }
1038
-
1039
- export interface TSInterfaceDeclaration extends BaseNode {
1040
- type: "TSInterfaceDeclaration";
1041
- id: Identifier;
1042
- typeParameters?: TSTypeParameterDeclaration;
1043
- extends?: TSExpressionWithTypeArguments[];
1044
- body: TSInterfaceBody;
1045
- declare?: boolean;
1046
- }
1047
-
1048
- export interface TSInterfaceBody extends BaseNode {
1049
- type: "TSInterfaceBody";
1050
- body: TypeElement[];
1051
- }
1052
-
1053
- /** An interface's `extends` or a class's `implements` entry. */
1054
- export interface TSExpressionWithTypeArguments extends BaseNode {
1055
- type: "TSExpressionWithTypeArguments";
1056
- expression: EntityName;
1057
- /** The type arguments, named `typeParameters` as in acorn-typescript. */
1058
- typeParameters?: TSTypeParameterInstantiation;
1059
- }
1060
-
1061
- export interface TSTypeAliasDeclaration extends BaseNode {
1062
- type: "TSTypeAliasDeclaration";
1063
- id: Identifier;
1064
- typeParameters?: TSTypeParameterDeclaration;
1065
- typeAnnotation: TypeNode;
1066
- declare?: boolean;
1067
- }
1068
-
1069
- export interface TSEnumDeclaration extends BaseNode {
1070
- type: "TSEnumDeclaration";
1071
- id: Identifier;
1072
- members: TSEnumMember[];
1073
- const?: boolean;
1074
- declare?: boolean;
1075
- }
1076
-
1077
- export interface TSEnumMember extends BaseNode {
1078
- type: "TSEnumMember";
1079
- id: Identifier | StringLiteral;
1080
- initializer?: Expression;
1081
- }
1082
-
1083
- /** `namespace A {}`, `module "a" {}`, `declare global {}`; `namespace A.B {}` nests through `body`. */
1084
- export interface TSModuleDeclaration extends BaseNode {
1085
- type: "TSModuleDeclaration";
1086
- id: Identifier | StringLiteral;
1087
- /** Absent for `declare module "a";`. */
1088
- body?: TSModuleBlock | TSModuleDeclaration;
1089
- declare?: boolean;
1090
- global?: boolean;
1091
- }
1092
-
1093
- export interface TSModuleBlock extends BaseNode {
1094
- type: "TSModuleBlock";
1095
- body: Array<Statement | ModuleDeclaration>;
1096
- }
1097
-
1098
- /** A function declaration without a body: an overload or `declare function`. */
1099
- export interface TSDeclareFunction extends BaseNode, TSFunctionFields {
1100
- type: "TSDeclareFunction";
1101
- /** `null` in `export default function (): void;`. */
1102
- id: Identifier | null;
1103
- params: Pattern[];
1104
- expression: boolean;
1105
- generator: boolean;
1106
- async: boolean;
1107
- declare?: boolean;
1108
- }
1109
-
1110
- /** A `MethodDefinition`'s value when the method has no body: an overload or an abstract method. */
1111
- export interface TSDeclareMethod extends BaseNode, TSFunctionFields {
1112
- type: "TSDeclareMethod";
1113
- id: null;
1114
- params: Array<Pattern | TSParameterProperty>;
1115
- expression: boolean;
1116
- generator: boolean;
1117
- async: boolean;
1118
- }
1119
-
1120
- /** `constructor(private a: T)`: a constructor parameter with a modifier. */
1121
- export interface TSParameterProperty extends BaseNode {
1122
- type: "TSParameterProperty";
1123
- accessibility?: Accessibility;
1124
- readonly?: boolean;
1125
- override?: boolean;
1126
- parameter: Identifier | AssignmentPattern;
1127
- }
1128
-
1129
- /** `import a = require("a")`, `import a = B.C`, `export import a = B.C`. */
1130
- export interface TSImportEqualsDeclaration extends BaseNode {
1131
- type: "TSImportEqualsDeclaration";
1132
- importKind: "type" | "value";
1133
- isExport: boolean;
1134
- id: Identifier;
1135
- moduleReference: EntityName | TSExternalModuleReference;
1136
- }
1137
-
1138
- export interface TSExternalModuleReference extends BaseNode {
1139
- type: "TSExternalModuleReference";
1140
- expression: StringLiteral;
1141
- }
1142
-
1143
- /** `export = a`. */
1144
- export interface TSExportAssignment extends BaseNode {
1145
- type: "TSExportAssignment";
1146
- expression: Expression;
1147
- }
1148
-
1149
- /** `export as namespace A`. */
1150
- export interface TSNamespaceExportDeclaration extends BaseNode {
1151
- type: "TSNamespaceExportDeclaration";
1152
- id: Identifier;
1153
- }
1154
-
1155
- export interface TSAsExpression extends BaseNode {
1156
- type: "TSAsExpression";
1157
- expression: Expression;
1158
- typeAnnotation: TypeNode;
1159
- }
1160
-
1161
- export interface TSSatisfiesExpression extends BaseNode {
1162
- type: "TSSatisfiesExpression";
1163
- expression: Expression;
1164
- typeAnnotation: TypeNode;
1165
- }
1166
-
1167
- /** `<T>a`. */
1168
- export interface TSTypeAssertion extends BaseNode {
1169
- type: "TSTypeAssertion";
1170
- typeAnnotation: TypeNode;
1171
- expression: Expression;
1172
- }
1173
-
1174
- export interface TSNonNullExpression extends BaseNode {
1175
- type: "TSNonNullExpression";
1176
- expression: Expression;
1177
- }
1178
-
1179
- /** `f<T>` without a call. */
1180
- export interface TSInstantiationExpression extends BaseNode {
1181
- type: "TSInstantiationExpression";
1182
- expression: Expression;
1183
- typeArguments: TSTypeParameterInstantiation;
1184
- }
1185
-
1186
- type Namespace = "html" | "svg" | "mathml";
95
+ type Namespace = "html" | "svg" | "mathml";
1187
96
 
1188
97
  export declare namespace AST {
1189
98
  export interface BaseNode {
@@ -1509,164 +418,1319 @@ export declare namespace AST {
1509
418
  export interface JSComment {
1510
419
  type: "Line" | "Block";
1511
420
  value: string;
1512
- start: number;
1513
- end: number;
1514
- /** Only with `parse(source, { loc: true })`. */
1515
- loc?: {
1516
- start: {
1517
- line: number;
1518
- column: number;
1519
- };
1520
- end: {
1521
- line: number;
1522
- column: number;
1523
- };
1524
- };
1525
- }
1526
- export type AttributeLike = Attribute | SpreadAttribute | Directive;
1527
- export type Directive = AST.AnimateDirective | AST.BindDirective | AST.ClassDirective | AST.LetDirective | AST.OnDirective | AST.StyleDirective | AST.TransitionDirective | AST.UseDirective;
1528
- export type Block = AST.EachBlock | AST.IfBlock | AST.AwaitBlock | AST.KeyBlock | AST.SnippetBlock;
1529
- export type ElementLike = AST.Component | AST.TitleElement | AST.SlotElement | AST.RegularElement | AST.SvelteBody | AST.SvelteBoundary | AST.SvelteComponent | AST.SvelteDocument | AST.SvelteElement | AST.SvelteFragment | AST.SvelteHead | AST.SvelteOptionsRaw | AST.SvelteSelf | AST.SvelteWindow | AST.SvelteBoundary;
1530
- export type Tag = AST.AttachTag | AST.ConstTag | AST.DeclarationTag | AST.DebugTag | AST.ExpressionTag | AST.HtmlTag | AST.RenderTag;
1531
- export type TemplateNode = AST.Root | AST.Text | Tag | ElementLike | AST.Attribute | AST.SpreadAttribute | Directive | AST.AttachTag | AST.Comment | Block;
1532
- export type SvelteNode = Node | TemplateNode | AST.Fragment | _CSS.Node | Script;
1533
- export type { _CSS as CSS };
421
+ start: number;
422
+ end: number;
423
+ /** Only with `parse(source, { loc: true })`. */
424
+ loc?: {
425
+ start: {
426
+ line: number;
427
+ column: number;
428
+ };
429
+ end: {
430
+ line: number;
431
+ column: number;
432
+ };
433
+ };
434
+ }
435
+ export type AttributeLike = Attribute | SpreadAttribute | Directive;
436
+ export type Directive = AST.AnimateDirective | AST.BindDirective | AST.ClassDirective | AST.LetDirective | AST.OnDirective | AST.StyleDirective | AST.TransitionDirective | AST.UseDirective;
437
+ export type Block = AST.EachBlock | AST.IfBlock | AST.AwaitBlock | AST.KeyBlock | AST.SnippetBlock;
438
+ export type ElementLike = AST.Component | AST.TitleElement | AST.SlotElement | AST.RegularElement | AST.SvelteBody | AST.SvelteBoundary | AST.SvelteComponent | AST.SvelteDocument | AST.SvelteElement | AST.SvelteFragment | AST.SvelteHead | AST.SvelteOptionsRaw | AST.SvelteSelf | AST.SvelteWindow | AST.SvelteBoundary;
439
+ export type Tag = AST.AttachTag | AST.ConstTag | AST.DeclarationTag | AST.DebugTag | AST.ExpressionTag | AST.HtmlTag | AST.RenderTag;
440
+ export type TemplateNode = AST.Root | AST.Text | Tag | ElementLike | AST.Attribute | AST.SpreadAttribute | Directive | AST.AttachTag | AST.Comment | Block;
441
+ export type SvelteNode = Node | TemplateNode | AST.Fragment | _CSS.Node | Script;
442
+ export type { _CSS as CSS };
443
+ }
444
+
445
+ declare namespace _CSS {
446
+ interface BaseNode {
447
+ start: number;
448
+ end: number;
449
+ }
450
+ interface StyleSheetBase extends BaseNode {
451
+ children: Array<Atrule | Rule>;
452
+ /** CSS comments in source order */
453
+ comments: CSSComment[];
454
+ }
455
+ interface CSSComment extends BaseNode {
456
+ type: "CSSComment";
457
+ value: string;
458
+ /** Character offset in a containing declaration value or at-rule prelude */
459
+ position?: number;
460
+ }
461
+ interface StyleSheetFile extends StyleSheetBase {
462
+ type: "StyleSheetFile";
463
+ }
464
+ interface StyleSheet extends StyleSheetBase {
465
+ type: "StyleSheet";
466
+ attributes: any[];
467
+ content: {
468
+ start: number;
469
+ end: number;
470
+ styles: string;
471
+ /** Possible comment atop the style tag */
472
+ comment: AST.Comment | null;
473
+ };
474
+ }
475
+ interface Atrule extends BaseNode {
476
+ type: "Atrule";
477
+ name: string;
478
+ prelude: string;
479
+ block: Block | null;
480
+ }
481
+ interface Rule extends BaseNode {
482
+ type: "Rule";
483
+ prelude: SelectorList;
484
+ block: Block;
485
+ }
486
+ /**
487
+ * A list of selectors, e.g. `a, b, c {}`
488
+ */
489
+ interface SelectorList extends BaseNode {
490
+ type: "SelectorList";
491
+ /**
492
+ * The `a`, `b` and `c` in `a, b, c {}`
493
+ */
494
+ children: ComplexSelector[];
495
+ }
496
+ /**
497
+ * A complex selector, e.g. `a b c {}`
498
+ */
499
+ interface ComplexSelector extends BaseNode {
500
+ type: "ComplexSelector";
501
+ /**
502
+ * The `a`, `b` and `c` in `a b c {}`
503
+ */
504
+ children: RelativeSelector[];
505
+ }
506
+ /**
507
+ * A relative selector, e.g the `a` and `> b` in `a > b {}`
508
+ */
509
+ interface RelativeSelector extends BaseNode {
510
+ type: "RelativeSelector";
511
+ /**
512
+ * In `a > b`, `> b` forms one relative selector, and `>` is the combinator. `null` for the first selector.
513
+ */
514
+ combinator: null | Combinator;
515
+ /**
516
+ * The `b:is(...)` in `> b:is(...)`
517
+ */
518
+ selectors: SimpleSelector[];
519
+ }
520
+ interface TypeSelector extends BaseNode {
521
+ type: "TypeSelector";
522
+ name: string;
523
+ namespace?: string;
524
+ }
525
+ interface IdSelector extends BaseNode {
526
+ type: "IdSelector";
527
+ name: string;
528
+ }
529
+ interface ClassSelector extends BaseNode {
530
+ type: "ClassSelector";
531
+ name: string;
532
+ }
533
+ interface AttributeSelector extends BaseNode {
534
+ type: "AttributeSelector";
535
+ name: string;
536
+ matcher: string | null;
537
+ value: string | null;
538
+ flags: string | null;
539
+ }
540
+ interface PseudoElementSelector extends BaseNode {
541
+ type: "PseudoElementSelector";
542
+ name: string;
543
+ args?: SelectorList;
544
+ }
545
+ interface PseudoClassSelector extends BaseNode {
546
+ type: "PseudoClassSelector";
547
+ name: string;
548
+ args: SelectorList | null;
549
+ }
550
+ interface Percentage extends BaseNode {
551
+ type: "Percentage";
552
+ value: string;
553
+ }
554
+ interface NestingSelector extends BaseNode {
555
+ type: "NestingSelector";
556
+ name: "&";
557
+ }
558
+ interface Nth extends BaseNode {
559
+ type: "Nth";
560
+ value: string;
561
+ }
562
+ type SimpleSelector = TypeSelector | IdSelector | ClassSelector | AttributeSelector | PseudoElementSelector | PseudoClassSelector | Percentage | Nth | NestingSelector;
563
+ interface Combinator extends BaseNode {
564
+ type: "Combinator";
565
+ name: string;
566
+ }
567
+ interface Block extends BaseNode {
568
+ type: "Block";
569
+ children: Array<Declaration | Rule | Atrule>;
570
+ }
571
+ interface Declaration extends BaseNode {
572
+ type: "Declaration";
573
+ property: string;
574
+ value: string;
575
+ }
576
+ type Node = StyleSheet | Rule | Atrule | SelectorList | Block | ComplexSelector | RelativeSelector | Combinator | SimpleSelector | Declaration;
577
+ }
578
+
579
+ export interface BaseNodeWithoutComments {
580
+ type: string;
581
+ start: number;
582
+ end: number;
583
+ loc?: SourceLocation | null | undefined;
584
+ range?: [number, number] | undefined;
585
+ }
586
+
587
+ export interface BaseNode extends BaseNodeWithoutComments {
588
+ leadingComments?: Comment[] | undefined;
589
+ trailingComments?: Comment[] | undefined;
590
+ }
591
+
592
+ export interface NodeMap {
593
+ AssignmentProperty: AssignmentProperty;
594
+ CatchClause: CatchClause;
595
+ Class: Class;
596
+ ClassBody: ClassBody;
597
+ Expression: Expression;
598
+ Function: Function;
599
+ Identifier: Identifier;
600
+ Literal: Literal;
601
+ MethodDefinition: MethodDefinition;
602
+ ModuleDeclaration: ModuleDeclaration;
603
+ ModuleSpecifier: ModuleSpecifier;
604
+ Pattern: Pattern;
605
+ PrivateIdentifier: PrivateIdentifier;
606
+ Program: Program;
607
+ Property: Property;
608
+ PropertyDefinition: PropertyDefinition;
609
+ SpreadElement: SpreadElement;
610
+ Statement: Statement;
611
+ Super: Super;
612
+ SwitchCase: SwitchCase;
613
+ TemplateElement: TemplateElement;
614
+ VariableDeclarator: VariableDeclarator;
615
+ ImportAttribute: ImportAttribute;
616
+ TSNode: TSNode;
617
+ }
618
+
619
+ export type Node = NodeMap[keyof NodeMap];
620
+
621
+ export interface Comment extends BaseNodeWithoutComments {
622
+ type: "Line" | "Block";
623
+ value: string;
624
+ }
625
+
626
+ export interface SourceLocation {
627
+ source?: string | null | undefined;
628
+ start: Position;
629
+ end: Position;
630
+ }
631
+
632
+ export interface Position {
633
+ /** >= 1 */
634
+ line: number;
635
+ /** >= 0 */
636
+ column: number;
637
+ }
638
+
639
+ export interface Program extends Omit<BaseNode, "leadingComments"> {
640
+ type: "Program";
641
+ sourceType: "script" | "module";
642
+ body: Array<Directive | Statement | ModuleDeclaration>;
643
+ comments?: Comment[] | undefined;
644
+ /** In a component's `<script>`, an HTML comment right before the tag becomes `{ type: "Line", value }`, without offsets, as in svelte. */
645
+ leadingComments?: Array<Comment | {
646
+ type: "Line";
647
+ value: string;
648
+ }> | undefined;
649
+ }
650
+
651
+ export interface Directive extends BaseNode {
652
+ type: "ExpressionStatement";
653
+ expression: Literal;
654
+ directive: string;
655
+ }
656
+
657
+ export interface BaseFunction extends BaseNode, TSFunctionFields {
658
+ params: Array<Pattern | TSParameterProperty>;
659
+ generator?: boolean | undefined;
660
+ async?: boolean | undefined;
661
+ body: BlockStatement | Expression;
662
+ }
663
+
664
+ export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
665
+
666
+ export type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
667
+
668
+ export interface BaseStatement extends BaseNode {
669
+ }
670
+
671
+ export interface EmptyStatement extends BaseStatement {
672
+ type: "EmptyStatement";
673
+ }
674
+
675
+ export interface BlockStatement extends BaseStatement {
676
+ type: "BlockStatement";
677
+ body: Statement[];
678
+ innerComments?: Comment[] | undefined;
679
+ }
680
+
681
+ export interface StaticBlock extends Omit<BlockStatement, "type"> {
682
+ type: "StaticBlock";
683
+ }
684
+
685
+ export interface ExpressionStatement extends BaseStatement {
686
+ type: "ExpressionStatement";
687
+ expression: Expression;
688
+ }
689
+
690
+ export interface IfStatement extends BaseStatement {
691
+ type: "IfStatement";
692
+ test: Expression;
693
+ consequent: Statement;
694
+ alternate?: Statement | null | undefined;
695
+ }
696
+
697
+ export interface LabeledStatement extends BaseStatement {
698
+ type: "LabeledStatement";
699
+ label: Identifier;
700
+ body: Statement;
701
+ }
702
+
703
+ export interface BreakStatement extends BaseStatement {
704
+ type: "BreakStatement";
705
+ label?: Identifier | null | undefined;
706
+ }
707
+
708
+ export interface ContinueStatement extends BaseStatement {
709
+ type: "ContinueStatement";
710
+ label?: Identifier | null | undefined;
711
+ }
712
+
713
+ export interface WithStatement extends BaseStatement {
714
+ type: "WithStatement";
715
+ object: Expression;
716
+ body: Statement;
717
+ }
718
+
719
+ export interface SwitchStatement extends BaseStatement {
720
+ type: "SwitchStatement";
721
+ discriminant: Expression;
722
+ cases: SwitchCase[];
723
+ }
724
+
725
+ export interface ReturnStatement extends BaseStatement {
726
+ type: "ReturnStatement";
727
+ argument?: Expression | null | undefined;
728
+ }
729
+
730
+ export interface ThrowStatement extends BaseStatement {
731
+ type: "ThrowStatement";
732
+ argument: Expression;
733
+ }
734
+
735
+ export interface TryStatement extends BaseStatement {
736
+ type: "TryStatement";
737
+ block: BlockStatement;
738
+ handler?: CatchClause | null | undefined;
739
+ finalizer?: BlockStatement | null | undefined;
740
+ }
741
+
742
+ export interface WhileStatement extends BaseStatement {
743
+ type: "WhileStatement";
744
+ test: Expression;
745
+ body: Statement;
746
+ }
747
+
748
+ export interface DoWhileStatement extends BaseStatement {
749
+ type: "DoWhileStatement";
750
+ body: Statement;
751
+ test: Expression;
752
+ }
753
+
754
+ export interface ForStatement extends BaseStatement {
755
+ type: "ForStatement";
756
+ init?: VariableDeclaration | Expression | null | undefined;
757
+ test?: Expression | null | undefined;
758
+ update?: Expression | null | undefined;
759
+ body: Statement;
760
+ }
761
+
762
+ export interface BaseForXStatement extends BaseStatement {
763
+ left: VariableDeclaration | Pattern;
764
+ right: Expression;
765
+ body: Statement;
766
+ }
767
+
768
+ export interface ForInStatement extends BaseForXStatement {
769
+ type: "ForInStatement";
770
+ }
771
+
772
+ export interface DebuggerStatement extends BaseStatement {
773
+ type: "DebuggerStatement";
774
+ }
775
+
776
+ export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | TSDeclaration;
777
+
778
+ export interface BaseDeclaration extends BaseStatement {
779
+ }
780
+
781
+ export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
782
+ type: "FunctionDeclaration";
783
+ /** It is null when a function declaration is a part of the `export default function` statement */
784
+ id: Identifier | null;
785
+ body: BlockStatement;
786
+ expression: false;
787
+ /** No `TSParameterProperty`: `private x` only parses in a class constructor, a `FunctionExpression`. */
788
+ params: Pattern[];
789
+ }
790
+
791
+ export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
792
+ id: Identifier;
793
+ }
794
+
795
+ export interface VariableDeclaration extends BaseDeclaration {
796
+ type: "VariableDeclaration";
797
+ declarations: VariableDeclarator[];
798
+ kind: "var" | "let" | "const" | "using" | "await using";
799
+ declare?: boolean;
800
+ }
801
+
802
+ export interface VariableDeclarator extends BaseNode {
803
+ type: "VariableDeclarator";
804
+ id: Pattern;
805
+ init?: Expression | null | undefined;
806
+ definite?: boolean;
807
+ }
808
+
809
+ export interface ExpressionMap {
810
+ ArrayExpression: ArrayExpression;
811
+ ArrowFunctionExpression: ArrowFunctionExpression;
812
+ AssignmentExpression: AssignmentExpression;
813
+ AwaitExpression: AwaitExpression;
814
+ BinaryExpression: BinaryExpression;
815
+ CallExpression: CallExpression;
816
+ ChainExpression: ChainExpression;
817
+ ClassExpression: ClassExpression;
818
+ ConditionalExpression: ConditionalExpression;
819
+ FunctionExpression: FunctionExpression;
820
+ Identifier: Identifier;
821
+ ImportExpression: ImportExpression;
822
+ Literal: Literal;
823
+ LogicalExpression: LogicalExpression;
824
+ MemberExpression: MemberExpression;
825
+ MetaProperty: MetaProperty;
826
+ NewExpression: NewExpression;
827
+ ObjectExpression: ObjectExpression;
828
+ SequenceExpression: SequenceExpression;
829
+ TaggedTemplateExpression: TaggedTemplateExpression;
830
+ TemplateLiteral: TemplateLiteral;
831
+ ThisExpression: ThisExpression;
832
+ UnaryExpression: UnaryExpression;
833
+ UpdateExpression: UpdateExpression;
834
+ YieldExpression: YieldExpression;
835
+ TSExpression: TSExpression;
836
+ }
837
+
838
+ export type Expression = ExpressionMap[keyof ExpressionMap];
839
+
840
+ export interface BaseExpression extends BaseNode {
841
+ }
842
+
843
+ export type ChainElement = SimpleCallExpression | MemberExpression;
844
+
845
+ export interface ChainExpression extends BaseExpression {
846
+ type: "ChainExpression";
847
+ expression: ChainElement;
848
+ }
849
+
850
+ export interface ThisExpression extends BaseExpression {
851
+ type: "ThisExpression";
852
+ }
853
+
854
+ export interface ArrayExpression extends BaseExpression {
855
+ type: "ArrayExpression";
856
+ elements: Array<Expression | SpreadElement | null>;
857
+ }
858
+
859
+ export interface ObjectExpression extends BaseExpression {
860
+ type: "ObjectExpression";
861
+ properties: Array<Property | SpreadElement>;
862
+ }
863
+
864
+ export interface PrivateIdentifier extends BaseNode {
865
+ type: "PrivateIdentifier";
866
+ name: string;
867
+ }
868
+
869
+ export interface Property extends BaseNode {
870
+ type: "Property";
871
+ key: Expression;
872
+ value: Expression | Pattern;
873
+ kind: "init" | "get" | "set";
874
+ method: boolean;
875
+ shorthand: boolean;
876
+ computed: boolean;
877
+ decorators?: Decorator[];
878
+ }
879
+
880
+ export interface PropertyDefinition extends BaseNode, TSClassMemberFields {
881
+ type: "PropertyDefinition";
882
+ key: Expression | PrivateIdentifier;
883
+ value?: Expression | null | undefined;
884
+ computed: boolean;
885
+ static: boolean;
886
+ typeAnnotation?: TSTypeAnnotation;
887
+ definite?: boolean;
888
+ }
889
+
890
+ export interface FunctionExpression extends BaseFunction, BaseExpression {
891
+ id?: Identifier | null | undefined;
892
+ type: "FunctionExpression";
893
+ body: BlockStatement;
894
+ expression: false;
895
+ }
896
+
897
+ export interface SequenceExpression extends BaseExpression {
898
+ type: "SequenceExpression";
899
+ expressions: Expression[];
900
+ }
901
+
902
+ export interface UnaryExpression extends BaseExpression {
903
+ type: "UnaryExpression";
904
+ operator: UnaryOperator;
905
+ prefix: true;
906
+ argument: Expression;
907
+ }
908
+
909
+ export interface BinaryExpression extends BaseExpression {
910
+ type: "BinaryExpression";
911
+ operator: BinaryOperator;
912
+ left: Expression | PrivateIdentifier;
913
+ right: Expression;
914
+ }
915
+
916
+ export interface AssignmentExpression extends BaseExpression {
917
+ type: "AssignmentExpression";
918
+ operator: AssignmentOperator;
919
+ left: Pattern | MemberExpression | TSAsExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
920
+ right: Expression;
921
+ }
922
+
923
+ export interface UpdateExpression extends BaseExpression {
924
+ type: "UpdateExpression";
925
+ operator: UpdateOperator;
926
+ argument: Expression;
927
+ prefix: boolean;
928
+ }
929
+
930
+ export interface LogicalExpression extends BaseExpression {
931
+ type: "LogicalExpression";
932
+ operator: LogicalOperator;
933
+ left: Expression;
934
+ right: Expression;
935
+ }
936
+
937
+ export interface ConditionalExpression extends BaseExpression {
938
+ type: "ConditionalExpression";
939
+ test: Expression;
940
+ alternate: Expression;
941
+ consequent: Expression;
942
+ }
943
+
944
+ export interface BaseCallExpression extends BaseExpression {
945
+ callee: Expression | Super;
946
+ arguments: Array<Expression | SpreadElement>;
947
+ typeArguments?: TSTypeParameterInstantiation;
948
+ }
949
+
950
+ export type CallExpression = SimpleCallExpression | NewExpression;
951
+
952
+ export interface SimpleCallExpression extends BaseCallExpression {
953
+ type: "CallExpression";
954
+ /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
955
+ optional?: boolean;
956
+ }
957
+
958
+ export interface NewExpression extends BaseCallExpression {
959
+ type: "NewExpression";
960
+ }
961
+
962
+ export interface MemberExpression extends BaseExpression, BasePattern {
963
+ type: "MemberExpression";
964
+ object: Expression | Super;
965
+ property: Expression | PrivateIdentifier;
966
+ computed: boolean;
967
+ /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
968
+ optional?: boolean;
969
+ }
970
+
971
+ export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
972
+
973
+ export interface BasePattern extends BaseNode {
974
+ }
975
+
976
+ export interface SwitchCase extends BaseNode {
977
+ type: "SwitchCase";
978
+ test?: Expression | null | undefined;
979
+ consequent: Statement[];
980
+ }
981
+
982
+ export interface CatchClause extends BaseNode {
983
+ type: "CatchClause";
984
+ param: Pattern | null;
985
+ body: BlockStatement;
986
+ }
987
+
988
+ export interface Identifier extends BaseNode, BaseExpression, BasePattern, TSBindingFields {
989
+ type: "Identifier";
990
+ name: string;
991
+ }
992
+
993
+ export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
994
+
995
+ export interface SimpleLiteral extends BaseNode, BaseExpression {
996
+ type: "Literal";
997
+ value: string | boolean | number | null;
998
+ raw?: string | undefined;
999
+ }
1000
+
1001
+ /** A string `Literal`: a module specifier, an import attribute, or a quoted module export name. */
1002
+ export interface StringLiteral extends SimpleLiteral {
1003
+ value: string;
1004
+ }
1005
+
1006
+ export interface RegExpLiteral extends BaseNode, BaseExpression {
1007
+ type: "Literal";
1008
+ value?: RegExp | null | undefined;
1009
+ regex: {
1010
+ pattern: string;
1011
+ flags: string;
1012
+ };
1013
+ raw?: string | undefined;
1014
+ }
1015
+
1016
+ export interface BigIntLiteral extends BaseNode, BaseExpression {
1017
+ type: "Literal";
1018
+ value?: bigint | null | undefined;
1019
+ bigint: string;
1020
+ raw?: string | undefined;
1021
+ }
1022
+
1023
+ export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
1024
+
1025
+ export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
1026
+
1027
+ export type LogicalOperator = "||" | "&&" | "??";
1028
+
1029
+ export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
1030
+
1031
+ export type UpdateOperator = "++" | "--";
1032
+
1033
+ export interface ForOfStatement extends BaseForXStatement {
1034
+ type: "ForOfStatement";
1035
+ await: boolean;
1036
+ }
1037
+
1038
+ export interface Super extends BaseNode {
1039
+ type: "Super";
1040
+ }
1041
+
1042
+ export interface SpreadElement extends BaseNode {
1043
+ type: "SpreadElement";
1044
+ argument: Expression;
1045
+ }
1046
+
1047
+ export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
1048
+ type: "ArrowFunctionExpression";
1049
+ expression: boolean;
1050
+ body: BlockStatement | Expression;
1051
+ id: null;
1052
+ /** No `TSParameterProperty`: `private x` only parses in a class constructor, a `FunctionExpression`. */
1053
+ params: Pattern[];
1054
+ }
1055
+
1056
+ export interface YieldExpression extends BaseExpression {
1057
+ type: "YieldExpression";
1058
+ argument?: Expression | null | undefined;
1059
+ delegate: boolean;
1060
+ }
1061
+
1062
+ export interface TemplateLiteral extends BaseExpression {
1063
+ type: "TemplateLiteral";
1064
+ quasis: TemplateElement[];
1065
+ expressions: Expression[];
1066
+ }
1067
+
1068
+ export interface TaggedTemplateExpression extends BaseExpression {
1069
+ type: "TaggedTemplateExpression";
1070
+ tag: Expression;
1071
+ quasi: TemplateLiteral;
1072
+ typeArguments?: TSTypeParameterInstantiation;
1073
+ }
1074
+
1075
+ export interface TemplateElement extends BaseNode {
1076
+ type: "TemplateElement";
1077
+ tail: boolean;
1078
+ value: {
1079
+ /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
1080
+ cooked?: string | null | undefined;
1081
+ raw: string;
1082
+ };
1083
+ }
1084
+
1085
+ export interface AssignmentProperty extends Property {
1086
+ value: Pattern;
1087
+ kind: "init";
1088
+ method: boolean;
1089
+ }
1090
+
1091
+ export interface ObjectPattern extends BasePattern, TSBindingFields {
1092
+ type: "ObjectPattern";
1093
+ properties: Array<AssignmentProperty | RestElement>;
1094
+ }
1095
+
1096
+ export interface ArrayPattern extends BasePattern, TSBindingFields {
1097
+ type: "ArrayPattern";
1098
+ elements: Array<Pattern | null>;
1099
+ }
1100
+
1101
+ export interface RestElement extends BasePattern, TSBindingFields {
1102
+ type: "RestElement";
1103
+ argument: Pattern;
1104
+ }
1105
+
1106
+ export interface AssignmentPattern extends BasePattern {
1107
+ type: "AssignmentPattern";
1108
+ left: Pattern;
1109
+ right: Expression;
1110
+ decorators?: Decorator[];
1111
+ }
1112
+
1113
+ export type Class = ClassDeclaration | ClassExpression;
1114
+
1115
+ export interface BaseClass extends BaseNode, TSClassFields {
1116
+ superClass?: Expression | null | undefined;
1117
+ body: ClassBody;
1118
+ }
1119
+
1120
+ export interface ClassBody extends BaseNode {
1121
+ type: "ClassBody";
1122
+ body: Array<MethodDefinition | PropertyDefinition | StaticBlock | TSIndexSignature>;
1123
+ }
1124
+
1125
+ export interface MethodDefinition extends BaseNode, TSClassMemberFields {
1126
+ type: "MethodDefinition";
1127
+ key: Expression | PrivateIdentifier;
1128
+ value: FunctionExpression | TSDeclareMethod;
1129
+ kind: "constructor" | "method" | "get" | "set";
1130
+ computed: boolean;
1131
+ static: boolean;
1132
+ typeParameters?: TSTypeParameterDeclaration;
1133
+ }
1134
+
1135
+ export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
1136
+ type: "ClassDeclaration";
1137
+ /** It is null when a class declaration is a part of the `export default class` statement */
1138
+ id: Identifier | null;
1139
+ }
1140
+
1141
+ export interface ClassDeclaration extends MaybeNamedClassDeclaration {
1142
+ id: Identifier;
1143
+ }
1144
+
1145
+ export interface ClassExpression extends BaseClass, BaseExpression {
1146
+ type: "ClassExpression";
1147
+ id?: Identifier | null | undefined;
1148
+ }
1149
+
1150
+ export interface MetaProperty extends BaseExpression {
1151
+ type: "MetaProperty";
1152
+ meta: Identifier;
1153
+ property: Identifier;
1154
+ }
1155
+
1156
+ export type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | TSModuleDeclarationStatement;
1157
+
1158
+ export interface BaseModuleDeclaration extends BaseNode {
1159
+ }
1160
+
1161
+ export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
1162
+
1163
+ export interface BaseModuleSpecifier extends BaseNode {
1164
+ local: Identifier;
1165
+ }
1166
+
1167
+ export interface ImportDeclaration extends BaseModuleDeclaration {
1168
+ type: "ImportDeclaration";
1169
+ specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
1170
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
1171
+ attributes?: ImportAttribute[] | undefined;
1172
+ source: StringLiteral;
1173
+ importKind?: "type" | "value";
1174
+ }
1175
+
1176
+ export interface ImportSpecifier extends BaseModuleSpecifier {
1177
+ type: "ImportSpecifier";
1178
+ imported: Identifier | StringLiteral;
1179
+ importKind?: "type" | "value";
1180
+ }
1181
+
1182
+ export interface ImportAttribute extends BaseNode {
1183
+ type: "ImportAttribute";
1184
+ key: Identifier | StringLiteral;
1185
+ value: StringLiteral;
1186
+ }
1187
+
1188
+ export interface ImportExpression extends BaseExpression {
1189
+ type: "ImportExpression";
1190
+ source: Expression;
1191
+ options?: Expression | null | undefined;
1192
+ /** The import attributes, with `typescript: true`; `options` otherwise. */
1193
+ arguments?: Expression[];
1194
+ }
1195
+
1196
+ export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
1197
+ type: "ImportDefaultSpecifier";
1198
+ }
1199
+
1200
+ export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
1201
+ type: "ImportNamespaceSpecifier";
1202
+ }
1203
+
1204
+ export interface ExportNamedDeclaration extends BaseModuleDeclaration {
1205
+ type: "ExportNamedDeclaration";
1206
+ declaration?: Declaration | null | undefined;
1207
+ specifiers: ExportSpecifier[];
1208
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
1209
+ attributes?: ImportAttribute[] | undefined;
1210
+ source?: StringLiteral | null | undefined;
1211
+ exportKind?: "type" | "value";
1212
+ }
1213
+
1214
+ export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
1215
+ type: "ExportSpecifier";
1216
+ local: Identifier | StringLiteral;
1217
+ exported: Identifier | StringLiteral;
1218
+ exportKind?: "type" | "value";
1219
+ }
1220
+
1221
+ export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
1222
+ type: "ExportDefaultDeclaration";
1223
+ declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression | TSDeclareFunction | TSInterfaceDeclaration;
1224
+ exportKind?: "type" | "value";
1225
+ }
1226
+
1227
+ export interface ExportAllDeclaration extends BaseModuleDeclaration {
1228
+ type: "ExportAllDeclaration";
1229
+ exported: Identifier | StringLiteral | null;
1230
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
1231
+ attributes?: ImportAttribute[] | undefined;
1232
+ source: StringLiteral;
1233
+ exportKind?: "type" | "value";
1234
+ }
1235
+
1236
+ export interface AwaitExpression extends BaseExpression {
1237
+ type: "AwaitExpression";
1238
+ argument: Expression;
1239
+ }
1240
+
1241
+ export type TSNode = Decorator | TSTypeAnnotation | TypeNode | TSTypePredicate | TSNamedTupleMember | TSOptionalType | TSRestType | TemplateLiteralType | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSQualifiedName | TypeElement | TSInterfaceBody | TSExpressionWithTypeArguments | TSEnumMember | TSModuleBlock | TSExternalModuleReference | TSParameterProperty | TSDeclareMethod | TSDeclaration | TSModuleDeclarationStatement | TSExpression;
1242
+
1243
+ /** Declarations; in estree's `Declaration` union. */
1244
+ export type TSDeclaration = TSDeclareFunction | TSEnumDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSTypeAliasDeclaration;
1245
+
1246
+ /** Module-level statements; in estree's `ModuleDeclaration` union. */
1247
+ export type TSModuleDeclarationStatement = TSExportAssignment | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
1248
+
1249
+ /** Expressions; in estree's `Expression` union. */
1250
+ export type TSExpression = TSAsExpression | TSInstantiationExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
1251
+
1252
+ export type TypeNode = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSParenthesizedType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperator | TSTypeQuery | TSTypeReference | TSUnionType;
1253
+
1254
+ export type TypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature | TSMethodSignature | TSPropertySignature;
1255
+
1256
+ export type EntityName = Identifier | TSQualifiedName;
1257
+
1258
+ export type Accessibility = "public" | "private" | "protected";
1259
+
1260
+ /** A parameter of a function type, method signature or declared function. */
1261
+ export type SignatureParameter = Identifier | ObjectPattern | ArrayPattern | RestElement;
1262
+
1263
+ /** Fields the plugin adds to `Identifier`, `ObjectPattern`, `ArrayPattern` and `RestElement`. */
1264
+ export interface TSBindingFields {
1265
+ typeAnnotation?: TSTypeAnnotation | undefined;
1266
+ /** `a?` in a parameter list. */
1267
+ optional?: boolean;
1268
+ decorators?: Decorator[];
1269
+ }
1270
+
1271
+ /** Fields the plugin adds to functions. */
1272
+ export interface TSFunctionFields {
1273
+ typeParameters?: TSTypeParameterDeclaration;
1274
+ returnType?: TSTypeAnnotation;
1275
+ }
1276
+
1277
+ /** Fields the plugin adds to classes. */
1278
+ export interface TSClassFields {
1279
+ typeParameters?: TSTypeParameterDeclaration;
1280
+ superTypeParameters?: TSTypeParameterInstantiation;
1281
+ implements?: TSExpressionWithTypeArguments[];
1282
+ abstract?: boolean;
1283
+ declare?: boolean;
1284
+ decorators?: Decorator[];
1285
+ }
1286
+
1287
+ /** Modifiers the plugin adds to class members. */
1288
+ export interface TSClassMemberFields {
1289
+ accessibility?: Accessibility;
1290
+ abstract?: boolean;
1291
+ override?: boolean;
1292
+ readonly?: boolean;
1293
+ declare?: boolean;
1294
+ accessor?: boolean;
1295
+ optional?: boolean;
1296
+ decorators?: Decorator[];
1297
+ }
1298
+
1299
+ export interface Decorator extends BaseNode {
1300
+ type: "Decorator";
1301
+ expression: Expression;
1302
+ }
1303
+
1304
+ export interface TSTypeAnnotation extends BaseNode {
1305
+ type: "TSTypeAnnotation";
1306
+ /** A predicate (`x is T`, `asserts x`) only in a return type. */
1307
+ typeAnnotation: TypeNode | TSTypePredicate;
1308
+ }
1309
+
1310
+ export interface TSTypePredicate extends BaseNode {
1311
+ type: "TSTypePredicate";
1312
+ parameterName: Identifier | TSThisType;
1313
+ asserts: boolean;
1314
+ /** `null` for `asserts x` without `is`. */
1315
+ typeAnnotation: TSTypeAnnotation | null;
1316
+ }
1317
+
1318
+ export interface TSAnyKeyword extends BaseNode {
1319
+ type: "TSAnyKeyword";
1320
+ }
1321
+
1322
+ export interface TSBigIntKeyword extends BaseNode {
1323
+ type: "TSBigIntKeyword";
1324
+ }
1325
+
1326
+ export interface TSBooleanKeyword extends BaseNode {
1327
+ type: "TSBooleanKeyword";
1328
+ }
1329
+
1330
+ export interface TSNeverKeyword extends BaseNode {
1331
+ type: "TSNeverKeyword";
1332
+ }
1333
+
1334
+ export interface TSNullKeyword extends BaseNode {
1335
+ type: "TSNullKeyword";
1336
+ }
1337
+
1338
+ export interface TSNumberKeyword extends BaseNode {
1339
+ type: "TSNumberKeyword";
1340
+ }
1341
+
1342
+ export interface TSObjectKeyword extends BaseNode {
1343
+ type: "TSObjectKeyword";
1344
+ }
1345
+
1346
+ export interface TSStringKeyword extends BaseNode {
1347
+ type: "TSStringKeyword";
1348
+ }
1349
+
1350
+ export interface TSSymbolKeyword extends BaseNode {
1351
+ type: "TSSymbolKeyword";
1352
+ }
1353
+
1354
+ export interface TSUndefinedKeyword extends BaseNode {
1355
+ type: "TSUndefinedKeyword";
1356
+ }
1357
+
1358
+ export interface TSUnknownKeyword extends BaseNode {
1359
+ type: "TSUnknownKeyword";
1360
+ }
1361
+
1362
+ export interface TSVoidKeyword extends BaseNode {
1363
+ type: "TSVoidKeyword";
1364
+ }
1365
+
1366
+ export interface TSThisType extends BaseNode {
1367
+ type: "TSThisType";
1368
+ }
1369
+
1370
+ export interface TSArrayType extends BaseNode {
1371
+ type: "TSArrayType";
1372
+ elementType: TypeNode;
1373
+ }
1374
+
1375
+ export interface TSConditionalType extends BaseNode {
1376
+ type: "TSConditionalType";
1377
+ checkType: TypeNode;
1378
+ extendsType: TypeNode;
1379
+ trueType: TypeNode;
1380
+ falseType: TypeNode;
1381
+ }
1382
+
1383
+ export interface TSFunctionType extends BaseNode {
1384
+ type: "TSFunctionType";
1385
+ typeParameters?: TSTypeParameterDeclaration;
1386
+ parameters: SignatureParameter[];
1387
+ typeAnnotation: TSTypeAnnotation;
1388
+ }
1389
+
1390
+ export interface TSConstructorType extends BaseNode {
1391
+ type: "TSConstructorType";
1392
+ abstract: boolean;
1393
+ typeParameters?: TSTypeParameterDeclaration;
1394
+ parameters: SignatureParameter[];
1395
+ typeAnnotation: TSTypeAnnotation;
1396
+ }
1397
+
1398
+ export interface TSImportType extends BaseNode {
1399
+ type: "TSImportType";
1400
+ argument: StringLiteral;
1401
+ qualifier?: EntityName;
1402
+ typeArguments?: TSTypeParameterInstantiation;
1403
+ }
1404
+
1405
+ export interface TSIndexedAccessType extends BaseNode {
1406
+ type: "TSIndexedAccessType";
1407
+ objectType: TypeNode;
1408
+ indexType: TypeNode;
1409
+ }
1410
+
1411
+ export interface TSInferType extends BaseNode {
1412
+ type: "TSInferType";
1413
+ typeParameter: TSTypeParameter;
1414
+ }
1415
+
1416
+ export interface TSIntersectionType extends BaseNode {
1417
+ type: "TSIntersectionType";
1418
+ types: TypeNode[];
1419
+ }
1420
+
1421
+ export interface TSUnionType extends BaseNode {
1422
+ type: "TSUnionType";
1423
+ types: TypeNode[];
1424
+ }
1425
+
1426
+ export interface TSLiteralType extends BaseNode {
1427
+ type: "TSLiteralType";
1428
+ /** `UnaryExpression` for a negative number, e.g. `-1`. */
1429
+ literal: Literal | UnaryExpression | TemplateLiteralType;
1430
+ }
1431
+
1432
+ /** A template literal type, `` `prefix-${T}` ``: a `TemplateLiteral` whose expressions are types. */
1433
+ export interface TemplateLiteralType extends BaseNode {
1434
+ type: "TemplateLiteral";
1435
+ quasis: TemplateElement[];
1436
+ expressions: TypeNode[];
1437
+ }
1438
+
1439
+ export interface TSMappedType extends BaseNode {
1440
+ type: "TSMappedType";
1441
+ readonly?: true | "+" | "-";
1442
+ typeParameter: TSTypeParameter;
1443
+ /** The `as` clause. */
1444
+ nameType: TypeNode | null;
1445
+ optional?: true | "+" | "-";
1446
+ typeAnnotation?: TypeNode;
1447
+ }
1448
+
1449
+ export interface TSParenthesizedType extends BaseNode {
1450
+ type: "TSParenthesizedType";
1451
+ typeAnnotation: TypeNode;
1452
+ }
1453
+
1454
+ export interface TSTupleType extends BaseNode {
1455
+ type: "TSTupleType";
1456
+ elementTypes: Array<TypeNode | TSNamedTupleMember | TSOptionalType | TSRestType>;
1457
+ }
1458
+
1459
+ export interface TSNamedTupleMember extends BaseNode {
1460
+ type: "TSNamedTupleMember";
1461
+ label: Identifier;
1462
+ optional: boolean;
1463
+ elementType: TypeNode;
1464
+ }
1465
+
1466
+ export interface TSOptionalType extends BaseNode {
1467
+ type: "TSOptionalType";
1468
+ typeAnnotation: TypeNode;
1469
+ }
1470
+
1471
+ export interface TSRestType extends BaseNode {
1472
+ type: "TSRestType";
1473
+ typeAnnotation: TypeNode | TSNamedTupleMember;
1474
+ }
1475
+
1476
+ export interface TSTypeLiteral extends BaseNode {
1477
+ type: "TSTypeLiteral";
1478
+ members: TypeElement[];
1479
+ }
1480
+
1481
+ export interface TSTypeOperator extends BaseNode {
1482
+ type: "TSTypeOperator";
1483
+ operator: "keyof" | "unique" | "readonly";
1484
+ typeAnnotation: TypeNode;
1485
+ }
1486
+
1487
+ export interface TSTypeQuery extends BaseNode {
1488
+ type: "TSTypeQuery";
1489
+ exprName: EntityName | TSImportType;
1490
+ typeArguments?: TSTypeParameterInstantiation;
1491
+ }
1492
+
1493
+ export interface TSTypeReference extends BaseNode {
1494
+ type: "TSTypeReference";
1495
+ typeName: EntityName;
1496
+ typeArguments?: TSTypeParameterInstantiation;
1497
+ }
1498
+
1499
+ export interface TSQualifiedName extends BaseNode {
1500
+ type: "TSQualifiedName";
1501
+ left: EntityName;
1502
+ right: Identifier;
1503
+ }
1504
+
1505
+ export interface TSTypeParameterDeclaration extends BaseNode {
1506
+ type: "TSTypeParameterDeclaration";
1507
+ params: TSTypeParameter[];
1508
+ /** With a trailing comma, its offset. */
1509
+ extra?: {
1510
+ trailingComma: number;
1511
+ };
1512
+ }
1513
+
1514
+ export interface TSTypeParameter extends BaseNode {
1515
+ type: "TSTypeParameter";
1516
+ name: string;
1517
+ constraint?: TypeNode;
1518
+ default?: TypeNode;
1519
+ const?: true;
1520
+ in?: true;
1521
+ out?: true;
1522
+ }
1523
+
1524
+ export interface TSTypeParameterInstantiation extends BaseNode {
1525
+ type: "TSTypeParameterInstantiation";
1526
+ params: TypeNode[];
1527
+ }
1528
+
1529
+ export interface TSPropertySignature extends BaseNode {
1530
+ type: "TSPropertySignature";
1531
+ key: Expression;
1532
+ computed?: boolean;
1533
+ optional?: boolean;
1534
+ readonly?: boolean;
1535
+ typeAnnotation?: TSTypeAnnotation;
1536
+ }
1537
+
1538
+ export interface TSMethodSignature extends BaseNode {
1539
+ type: "TSMethodSignature";
1540
+ key: Expression;
1541
+ computed?: boolean;
1542
+ optional?: boolean;
1543
+ kind: "method" | "get" | "set";
1544
+ typeParameters?: TSTypeParameterDeclaration;
1545
+ parameters: SignatureParameter[];
1546
+ /** The return type. */
1547
+ typeAnnotation?: TSTypeAnnotation;
1548
+ }
1549
+
1550
+ /** In an interface, a type literal, or a class body (with the class member modifiers). */
1551
+ export interface TSIndexSignature extends BaseNode, TSClassMemberFields {
1552
+ type: "TSIndexSignature";
1553
+ parameters: Identifier[];
1554
+ typeAnnotation?: TSTypeAnnotation;
1555
+ static?: boolean;
1556
+ }
1557
+
1558
+ export interface TSCallSignatureDeclaration extends BaseNode {
1559
+ type: "TSCallSignatureDeclaration";
1560
+ typeParameters?: TSTypeParameterDeclaration;
1561
+ parameters: SignatureParameter[];
1562
+ typeAnnotation?: TSTypeAnnotation;
1563
+ }
1564
+
1565
+ export interface TSConstructSignatureDeclaration extends BaseNode {
1566
+ type: "TSConstructSignatureDeclaration";
1567
+ typeParameters?: TSTypeParameterDeclaration;
1568
+ parameters: SignatureParameter[];
1569
+ typeAnnotation?: TSTypeAnnotation;
1570
+ }
1571
+
1572
+ export interface TSInterfaceDeclaration extends BaseNode {
1573
+ type: "TSInterfaceDeclaration";
1574
+ id: Identifier;
1575
+ typeParameters?: TSTypeParameterDeclaration;
1576
+ extends?: TSExpressionWithTypeArguments[];
1577
+ body: TSInterfaceBody;
1578
+ declare?: boolean;
1579
+ }
1580
+
1581
+ export interface TSInterfaceBody extends BaseNode {
1582
+ type: "TSInterfaceBody";
1583
+ body: TypeElement[];
1584
+ }
1585
+
1586
+ /** An interface's `extends` or a class's `implements` entry. */
1587
+ export interface TSExpressionWithTypeArguments extends BaseNode {
1588
+ type: "TSExpressionWithTypeArguments";
1589
+ expression: EntityName;
1590
+ /** The type arguments, named `typeParameters` as in acorn-typescript. */
1591
+ typeParameters?: TSTypeParameterInstantiation;
1592
+ }
1593
+
1594
+ export interface TSTypeAliasDeclaration extends BaseNode {
1595
+ type: "TSTypeAliasDeclaration";
1596
+ id: Identifier;
1597
+ typeParameters?: TSTypeParameterDeclaration;
1598
+ typeAnnotation: TypeNode;
1599
+ declare?: boolean;
1600
+ }
1601
+
1602
+ export interface TSEnumDeclaration extends BaseNode {
1603
+ type: "TSEnumDeclaration";
1604
+ id: Identifier;
1605
+ members: TSEnumMember[];
1606
+ const?: boolean;
1607
+ declare?: boolean;
1608
+ }
1609
+
1610
+ export interface TSEnumMember extends BaseNode {
1611
+ type: "TSEnumMember";
1612
+ id: Identifier | StringLiteral;
1613
+ initializer?: Expression;
1614
+ }
1615
+
1616
+ /** `namespace A {}`, `module "a" {}`, `declare global {}`; `namespace A.B {}` nests through `body`. */
1617
+ export interface TSModuleDeclaration extends BaseNode {
1618
+ type: "TSModuleDeclaration";
1619
+ id: Identifier | StringLiteral;
1620
+ /** Absent for `declare module "a";`. */
1621
+ body?: TSModuleBlock | TSModuleDeclaration;
1622
+ declare?: boolean;
1623
+ global?: boolean;
1534
1624
  }
1535
1625
 
1536
- declare namespace _CSS {
1537
- interface BaseNode {
1538
- start: number;
1539
- end: number;
1540
- }
1541
- interface StyleSheetBase extends BaseNode {
1542
- children: Array<Atrule | Rule>;
1543
- /** CSS comments in source order */
1544
- comments: CSSComment[];
1545
- }
1546
- interface CSSComment extends BaseNode {
1547
- type: "CSSComment";
1548
- value: string;
1549
- /** Character offset in a containing declaration value or at-rule prelude */
1550
- position?: number;
1551
- }
1552
- interface StyleSheetFile extends StyleSheetBase {
1553
- type: "StyleSheetFile";
1554
- }
1555
- interface StyleSheet extends StyleSheetBase {
1556
- type: "StyleSheet";
1557
- attributes: any[];
1558
- content: {
1559
- start: number;
1560
- end: number;
1561
- styles: string;
1562
- /** Possible comment atop the style tag */
1563
- comment: AST.Comment | null;
1564
- };
1565
- }
1566
- interface Atrule extends BaseNode {
1567
- type: "Atrule";
1568
- name: string;
1569
- prelude: string;
1570
- block: Block | null;
1571
- }
1572
- interface Rule extends BaseNode {
1573
- type: "Rule";
1574
- prelude: SelectorList;
1575
- block: Block;
1576
- }
1577
- /**
1578
- * A list of selectors, e.g. `a, b, c {}`
1579
- */
1580
- interface SelectorList extends BaseNode {
1581
- type: "SelectorList";
1582
- /**
1583
- * The `a`, `b` and `c` in `a, b, c {}`
1584
- */
1585
- children: ComplexSelector[];
1586
- }
1587
- /**
1588
- * A complex selector, e.g. `a b c {}`
1589
- */
1590
- interface ComplexSelector extends BaseNode {
1591
- type: "ComplexSelector";
1592
- /**
1593
- * The `a`, `b` and `c` in `a b c {}`
1594
- */
1595
- children: RelativeSelector[];
1596
- }
1597
- /**
1598
- * A relative selector, e.g the `a` and `> b` in `a > b {}`
1599
- */
1600
- interface RelativeSelector extends BaseNode {
1601
- type: "RelativeSelector";
1602
- /**
1603
- * In `a > b`, `> b` forms one relative selector, and `>` is the combinator. `null` for the first selector.
1604
- */
1605
- combinator: null | Combinator;
1606
- /**
1607
- * The `b:is(...)` in `> b:is(...)`
1608
- */
1609
- selectors: SimpleSelector[];
1610
- }
1611
- interface TypeSelector extends BaseNode {
1612
- type: "TypeSelector";
1613
- name: string;
1614
- namespace?: string;
1615
- }
1616
- interface IdSelector extends BaseNode {
1617
- type: "IdSelector";
1618
- name: string;
1619
- }
1620
- interface ClassSelector extends BaseNode {
1621
- type: "ClassSelector";
1622
- name: string;
1623
- }
1624
- interface AttributeSelector extends BaseNode {
1625
- type: "AttributeSelector";
1626
- name: string;
1627
- matcher: string | null;
1628
- value: string | null;
1629
- flags: string | null;
1630
- }
1631
- interface PseudoElementSelector extends BaseNode {
1632
- type: "PseudoElementSelector";
1633
- name: string;
1634
- args?: SelectorList;
1635
- }
1636
- interface PseudoClassSelector extends BaseNode {
1637
- type: "PseudoClassSelector";
1638
- name: string;
1639
- args: SelectorList | null;
1640
- }
1641
- interface Percentage extends BaseNode {
1642
- type: "Percentage";
1643
- value: string;
1644
- }
1645
- interface NestingSelector extends BaseNode {
1646
- type: "NestingSelector";
1647
- name: "&";
1648
- }
1649
- interface Nth extends BaseNode {
1650
- type: "Nth";
1651
- value: string;
1652
- }
1653
- type SimpleSelector = TypeSelector | IdSelector | ClassSelector | AttributeSelector | PseudoElementSelector | PseudoClassSelector | Percentage | Nth | NestingSelector;
1654
- interface Combinator extends BaseNode {
1655
- type: "Combinator";
1656
- name: string;
1657
- }
1658
- interface Block extends BaseNode {
1659
- type: "Block";
1660
- children: Array<Declaration | Rule | Atrule>;
1661
- }
1662
- interface Declaration extends BaseNode {
1663
- type: "Declaration";
1664
- property: string;
1665
- value: string;
1666
- }
1667
- type Node = StyleSheet | Rule | Atrule | SelectorList | Block | ComplexSelector | RelativeSelector | Combinator | SimpleSelector | Declaration;
1626
+ export interface TSModuleBlock extends BaseNode {
1627
+ type: "TSModuleBlock";
1628
+ body: Array<Statement | ModuleDeclaration>;
1629
+ }
1630
+
1631
+ /** A function declaration without a body: an overload or `declare function`. */
1632
+ export interface TSDeclareFunction extends BaseNode, TSFunctionFields {
1633
+ type: "TSDeclareFunction";
1634
+ /** `null` in `export default function (): void;`. */
1635
+ id: Identifier | null;
1636
+ params: Pattern[];
1637
+ expression: boolean;
1638
+ generator: boolean;
1639
+ async: boolean;
1640
+ declare?: boolean;
1641
+ }
1642
+
1643
+ /** A `MethodDefinition`'s value when the method has no body: an overload or an abstract method. */
1644
+ export interface TSDeclareMethod extends BaseNode, TSFunctionFields {
1645
+ type: "TSDeclareMethod";
1646
+ id: null;
1647
+ params: Array<Pattern | TSParameterProperty>;
1648
+ expression: boolean;
1649
+ generator: boolean;
1650
+ async: boolean;
1651
+ }
1652
+
1653
+ /** `constructor(private a: T)`: a constructor parameter with a modifier. */
1654
+ export interface TSParameterProperty extends BaseNode {
1655
+ type: "TSParameterProperty";
1656
+ accessibility?: Accessibility;
1657
+ readonly?: boolean;
1658
+ override?: boolean;
1659
+ parameter: Identifier | AssignmentPattern;
1660
+ }
1661
+
1662
+ /** `import a = require("a")`, `import a = B.C`, `export import a = B.C`. */
1663
+ export interface TSImportEqualsDeclaration extends BaseNode {
1664
+ type: "TSImportEqualsDeclaration";
1665
+ importKind: "type" | "value";
1666
+ isExport: boolean;
1667
+ id: Identifier;
1668
+ moduleReference: EntityName | TSExternalModuleReference;
1669
+ }
1670
+
1671
+ export interface TSExternalModuleReference extends BaseNode {
1672
+ type: "TSExternalModuleReference";
1673
+ expression: StringLiteral;
1674
+ }
1675
+
1676
+ /** `export = a`. */
1677
+ export interface TSExportAssignment extends BaseNode {
1678
+ type: "TSExportAssignment";
1679
+ expression: Expression;
1680
+ }
1681
+
1682
+ /** `export as namespace A`. */
1683
+ export interface TSNamespaceExportDeclaration extends BaseNode {
1684
+ type: "TSNamespaceExportDeclaration";
1685
+ id: Identifier;
1686
+ }
1687
+
1688
+ export interface TSAsExpression extends BaseNode {
1689
+ type: "TSAsExpression";
1690
+ expression: Expression;
1691
+ typeAnnotation: TypeNode;
1692
+ }
1693
+
1694
+ export interface TSSatisfiesExpression extends BaseNode {
1695
+ type: "TSSatisfiesExpression";
1696
+ expression: Expression;
1697
+ typeAnnotation: TypeNode;
1698
+ }
1699
+
1700
+ /** `<T>a`. */
1701
+ export interface TSTypeAssertion extends BaseNode {
1702
+ type: "TSTypeAssertion";
1703
+ typeAnnotation: TypeNode;
1704
+ expression: Expression;
1705
+ }
1706
+
1707
+ export interface TSNonNullExpression extends BaseNode {
1708
+ type: "TSNonNullExpression";
1709
+ expression: Expression;
1710
+ }
1711
+
1712
+ /** `f<T>` without a call. */
1713
+ export interface TSInstantiationExpression extends BaseNode {
1714
+ type: "TSInstantiationExpression";
1715
+ expression: Expression;
1716
+ typeArguments: TSTypeParameterInstantiation;
1668
1717
  }
1669
1718
 
1719
+ /**
1720
+ * Parses only a module's top-level `import` and `export` statements, e.g.
1721
+ * to rewrite or follow its imports, and skips the rest without building
1722
+ * it. Each node is the one {@link parseModule} returns for the statement
1723
+ * with `comments: false`: `ImportDeclaration`, `ExportNamedDeclaration`,
1724
+ * `ExportDefaultDeclaration` and `ExportAllDeclaration`, plus, with
1725
+ * `typescript: true`, `TSImportEqualsDeclaration`, `TSExportAssignment`
1726
+ * and `TSNamespaceExportDeclaration`. `import(...)` and `import.meta`
1727
+ * aren't statements, so they aren't returned.
1728
+ *
1729
+ * Throws a {@link ParseError} (`js_parse_error`) on a syntax error in one
1730
+ * of those statements. Syntax errors in the rest aren't reported.
1731
+ */
1732
+ export declare function parseImportsExports(source: string, options?: ParseImportsExportsOptions): ModuleDeclaration[];
1733
+
1670
1734
  /**
1671
1735
  * Parses a JavaScript or TypeScript module, e.g. a `.ts` file a component
1672
1736
  * imports, into the same kind of AST as a component's `<script>`:
@@ -1675,12 +1739,7 @@ declare namespace _CSS {
1675
1739
  *
1676
1740
  * Throws a {@link ParseError} (`js_parse_error`) on a syntax error.
1677
1741
  */
1678
- export declare function parseModule(source: string, options?: {
1679
- /** Parse TypeScript. Default `false`. */
1680
- typescript?: boolean;
1681
- /** Add `loc` (line/column) to every node. Default `false`. */
1682
- loc?: boolean;
1683
- }): Program;
1742
+ export declare function parseModule(source: string, options?: ParseModuleOptions): Program;
1684
1743
 
1685
1744
  type NodeLike = number | {
1686
1745
  start?: number;
@@ -1716,3 +1775,271 @@ interface Location {
1716
1775
  column: number;
1717
1776
  character: number;
1718
1777
  }
1778
+
1779
+ /**
1780
+ * The fields of each node type that hold child nodes, in source order.
1781
+ * Typed against the AST, so a node type without an entry, or a key that
1782
+ * isn't one of its fields, fails typechecking. `tests/walk.test.ts` checks
1783
+ * the rest against the corpus: no field that holds a node is missing, and
1784
+ * children come in source order.
1785
+ */
1786
+ export declare const visitorKeys: {
1787
+ readonly Root: readonly ["module", "instance", "fragment", "css"];
1788
+ readonly Script: readonly ["attributes", "content"];
1789
+ readonly Fragment: readonly ["nodes"];
1790
+ readonly Text: readonly [];
1791
+ readonly Comment: readonly [];
1792
+ readonly ExpressionTag: readonly ["expression"];
1793
+ readonly HtmlTag: readonly ["expression"];
1794
+ readonly ConstTag: readonly ["declaration"];
1795
+ readonly DeclarationTag: readonly ["declaration"];
1796
+ readonly DebugTag: readonly ["identifiers"];
1797
+ readonly RenderTag: readonly ["expression"];
1798
+ readonly AttachTag: readonly ["expression"];
1799
+ readonly Attribute: readonly ["value"];
1800
+ readonly SpreadAttribute: readonly ["expression"];
1801
+ readonly AnimateDirective: readonly ["expression"];
1802
+ readonly BindDirective: readonly ["expression"];
1803
+ readonly ClassDirective: readonly ["expression"];
1804
+ readonly LetDirective: readonly ["expression"];
1805
+ readonly OnDirective: readonly ["expression"];
1806
+ readonly StyleDirective: readonly ["value"];
1807
+ readonly TransitionDirective: readonly ["expression"];
1808
+ readonly UseDirective: readonly ["expression"];
1809
+ readonly Component: readonly ["attributes", "fragment"];
1810
+ readonly TitleElement: readonly ["attributes", "fragment"];
1811
+ readonly SlotElement: readonly ["attributes", "fragment"];
1812
+ readonly RegularElement: readonly ["attributes", "fragment"];
1813
+ readonly SvelteBody: readonly ["attributes", "fragment"];
1814
+ readonly SvelteBoundary: readonly ["attributes", "fragment"];
1815
+ readonly SvelteComponent: readonly ["expression", "attributes", "fragment"];
1816
+ readonly SvelteDocument: readonly ["attributes", "fragment"];
1817
+ readonly SvelteElement: readonly ["tag", "attributes", "fragment"];
1818
+ readonly SvelteFragment: readonly ["attributes", "fragment"];
1819
+ readonly SvelteHead: readonly ["attributes", "fragment"];
1820
+ readonly SvelteOptions: readonly ["attributes", "fragment"];
1821
+ readonly SvelteSelf: readonly ["attributes", "fragment"];
1822
+ readonly SvelteWindow: readonly ["attributes", "fragment"];
1823
+ readonly IfBlock: readonly ["test", "consequent", "alternate"];
1824
+ readonly EachBlock: readonly ["expression", "context", "key", "body", "fallback"];
1825
+ readonly AwaitBlock: readonly ["expression", "pending", "value", "then", "error", "catch"];
1826
+ readonly KeyBlock: readonly ["expression", "fragment"];
1827
+ readonly SnippetBlock: readonly ["expression", "parameters", "body"];
1828
+ readonly StyleSheet: readonly ["attributes", "children"];
1829
+ readonly Rule: readonly ["prelude", "block"];
1830
+ readonly Atrule: readonly ["block"];
1831
+ readonly SelectorList: readonly ["children"];
1832
+ readonly ComplexSelector: readonly ["children"];
1833
+ readonly RelativeSelector: readonly ["combinator", "selectors"];
1834
+ readonly Combinator: readonly [];
1835
+ readonly TypeSelector: readonly [];
1836
+ readonly IdSelector: readonly [];
1837
+ readonly ClassSelector: readonly [];
1838
+ readonly AttributeSelector: readonly [];
1839
+ readonly PseudoElementSelector: readonly ["args"];
1840
+ readonly PseudoClassSelector: readonly ["args"];
1841
+ readonly Percentage: readonly [];
1842
+ readonly Nth: readonly [];
1843
+ readonly NestingSelector: readonly [];
1844
+ readonly Block: readonly ["children"];
1845
+ readonly Declaration: readonly [];
1846
+ readonly Program: readonly ["body"];
1847
+ readonly ExpressionStatement: readonly ["expression"];
1848
+ readonly BlockStatement: readonly ["body"];
1849
+ readonly StaticBlock: readonly ["body"];
1850
+ readonly EmptyStatement: readonly [];
1851
+ readonly DebuggerStatement: readonly [];
1852
+ readonly WithStatement: readonly ["object", "body"];
1853
+ readonly ReturnStatement: readonly ["argument"];
1854
+ readonly LabeledStatement: readonly ["label", "body"];
1855
+ readonly BreakStatement: readonly ["label"];
1856
+ readonly ContinueStatement: readonly ["label"];
1857
+ readonly IfStatement: readonly ["test", "consequent", "alternate"];
1858
+ readonly SwitchStatement: readonly ["discriminant", "cases"];
1859
+ readonly SwitchCase: readonly ["test", "consequent"];
1860
+ readonly ThrowStatement: readonly ["argument"];
1861
+ readonly TryStatement: readonly ["block", "handler", "finalizer"];
1862
+ readonly CatchClause: readonly ["param", "body"];
1863
+ readonly WhileStatement: readonly ["test", "body"];
1864
+ readonly DoWhileStatement: readonly ["body", "test"];
1865
+ readonly ForStatement: readonly ["init", "test", "update", "body"];
1866
+ readonly ForInStatement: readonly ["left", "right", "body"];
1867
+ readonly ForOfStatement: readonly ["left", "right", "body"];
1868
+ readonly FunctionDeclaration: readonly ["id", "typeParameters", "params", "returnType", "body"];
1869
+ readonly FunctionExpression: readonly ["id", "typeParameters", "params", "returnType", "body"];
1870
+ readonly ArrowFunctionExpression: readonly ["typeParameters", "params", "returnType", "body"];
1871
+ readonly VariableDeclaration: readonly ["declarations"];
1872
+ readonly VariableDeclarator: readonly ["id", "init"];
1873
+ readonly ClassDeclaration: readonly ["decorators", "id", "typeParameters", "superClass", "superTypeParameters", "implements", "body"];
1874
+ readonly ClassExpression: readonly ["decorators", "id", "typeParameters", "superClass", "superTypeParameters", "implements", "body"];
1875
+ readonly ClassBody: readonly ["body"];
1876
+ readonly MethodDefinition: readonly ["decorators", "key", "typeParameters", "value"];
1877
+ readonly PropertyDefinition: readonly ["decorators", "key", "typeAnnotation", "value"];
1878
+ readonly Property: readonly ["decorators", "key", "value"];
1879
+ readonly ThisExpression: readonly [];
1880
+ readonly Super: readonly [];
1881
+ readonly Literal: readonly [];
1882
+ readonly Identifier: readonly ["decorators", "typeAnnotation"];
1883
+ readonly PrivateIdentifier: readonly [];
1884
+ readonly ArrayExpression: readonly ["elements"];
1885
+ readonly ObjectExpression: readonly ["properties"];
1886
+ readonly UnaryExpression: readonly ["argument"];
1887
+ readonly UpdateExpression: readonly ["argument"];
1888
+ readonly BinaryExpression: readonly ["left", "right"];
1889
+ readonly LogicalExpression: readonly ["left", "right"];
1890
+ readonly AssignmentExpression: readonly ["left", "right"];
1891
+ readonly MemberExpression: readonly ["object", "property"];
1892
+ readonly ConditionalExpression: readonly ["test", "consequent", "alternate"];
1893
+ readonly CallExpression: readonly ["callee", "typeArguments", "arguments"];
1894
+ readonly NewExpression: readonly ["callee", "typeArguments", "arguments"];
1895
+ readonly SequenceExpression: readonly ["expressions"];
1896
+ readonly TemplateLiteral: readonly ["quasis", "expressions"];
1897
+ readonly TaggedTemplateExpression: readonly ["tag", "typeArguments", "quasi"];
1898
+ readonly TemplateElement: readonly [];
1899
+ readonly SpreadElement: readonly ["argument"];
1900
+ readonly RestElement: readonly ["decorators", "argument", "typeAnnotation"];
1901
+ readonly YieldExpression: readonly ["argument"];
1902
+ readonly AwaitExpression: readonly ["argument"];
1903
+ readonly ImportExpression: readonly ["source", "options", "arguments"];
1904
+ readonly ChainExpression: readonly ["expression"];
1905
+ readonly MetaProperty: readonly ["meta", "property"];
1906
+ readonly ObjectPattern: readonly ["decorators", "properties", "typeAnnotation"];
1907
+ readonly ArrayPattern: readonly ["decorators", "elements", "typeAnnotation"];
1908
+ readonly AssignmentPattern: readonly ["decorators", "left", "right"];
1909
+ readonly ImportDeclaration: readonly ["specifiers", "source", "attributes"];
1910
+ readonly ImportSpecifier: readonly ["imported", "local"];
1911
+ readonly ImportDefaultSpecifier: readonly ["local"];
1912
+ readonly ImportNamespaceSpecifier: readonly ["local"];
1913
+ readonly ImportAttribute: readonly ["key", "value"];
1914
+ readonly ExportNamedDeclaration: readonly ["declaration", "specifiers", "source", "attributes"];
1915
+ readonly ExportSpecifier: readonly ["local", "exported"];
1916
+ readonly ExportDefaultDeclaration: readonly ["declaration"];
1917
+ readonly ExportAllDeclaration: readonly ["exported", "source", "attributes"];
1918
+ readonly Decorator: readonly ["expression"];
1919
+ readonly TSTypeAnnotation: readonly ["typeAnnotation"];
1920
+ readonly TSTypeParameterDeclaration: readonly ["params"];
1921
+ readonly TSTypeParameterInstantiation: readonly ["params"];
1922
+ readonly TSTypeParameter: readonly ["constraint", "default"];
1923
+ readonly TSAnyKeyword: readonly [];
1924
+ readonly TSBigIntKeyword: readonly [];
1925
+ readonly TSBooleanKeyword: readonly [];
1926
+ readonly TSNeverKeyword: readonly [];
1927
+ readonly TSNullKeyword: readonly [];
1928
+ readonly TSNumberKeyword: readonly [];
1929
+ readonly TSObjectKeyword: readonly [];
1930
+ readonly TSStringKeyword: readonly [];
1931
+ readonly TSSymbolKeyword: readonly [];
1932
+ readonly TSUndefinedKeyword: readonly [];
1933
+ readonly TSUnknownKeyword: readonly [];
1934
+ readonly TSVoidKeyword: readonly [];
1935
+ readonly TSThisType: readonly [];
1936
+ readonly TSArrayType: readonly ["elementType"];
1937
+ readonly TSTupleType: readonly ["elementTypes"];
1938
+ readonly TSNamedTupleMember: readonly ["label", "elementType"];
1939
+ readonly TSOptionalType: readonly ["typeAnnotation"];
1940
+ readonly TSRestType: readonly ["typeAnnotation"];
1941
+ readonly TSUnionType: readonly ["types"];
1942
+ readonly TSIntersectionType: readonly ["types"];
1943
+ readonly TSConditionalType: readonly ["checkType", "extendsType", "trueType", "falseType"];
1944
+ readonly TSInferType: readonly ["typeParameter"];
1945
+ readonly TSParenthesizedType: readonly ["typeAnnotation"];
1946
+ readonly TSTypeOperator: readonly ["typeAnnotation"];
1947
+ readonly TSIndexedAccessType: readonly ["objectType", "indexType"];
1948
+ readonly TSMappedType: readonly ["typeParameter", "nameType", "typeAnnotation"];
1949
+ readonly TSLiteralType: readonly ["literal"];
1950
+ readonly TSTypeReference: readonly ["typeName", "typeArguments"];
1951
+ readonly TSQualifiedName: readonly ["left", "right"];
1952
+ readonly TSTypeQuery: readonly ["exprName", "typeArguments"];
1953
+ readonly TSImportType: readonly ["argument", "qualifier", "typeArguments"];
1954
+ readonly TSTypeLiteral: readonly ["members"];
1955
+ readonly TSPropertySignature: readonly ["key", "typeAnnotation"];
1956
+ readonly TSMethodSignature: readonly ["key", "typeParameters", "parameters", "typeAnnotation"];
1957
+ readonly TSCallSignatureDeclaration: readonly ["typeParameters", "parameters", "typeAnnotation"];
1958
+ readonly TSConstructSignatureDeclaration: readonly ["typeParameters", "parameters", "typeAnnotation"];
1959
+ readonly TSFunctionType: readonly ["typeParameters", "parameters", "typeAnnotation"];
1960
+ readonly TSConstructorType: readonly ["typeParameters", "parameters", "typeAnnotation"];
1961
+ readonly TSIndexSignature: readonly ["decorators", "parameters", "typeAnnotation"];
1962
+ readonly TSTypePredicate: readonly ["parameterName", "typeAnnotation"];
1963
+ readonly TSInterfaceDeclaration: readonly ["id", "typeParameters", "extends", "body"];
1964
+ readonly TSInterfaceBody: readonly ["body"];
1965
+ readonly TSExpressionWithTypeArguments: readonly ["expression", "typeParameters"];
1966
+ readonly TSTypeAliasDeclaration: readonly ["id", "typeParameters", "typeAnnotation"];
1967
+ readonly TSEnumDeclaration: readonly ["id", "members"];
1968
+ readonly TSEnumMember: readonly ["id", "initializer"];
1969
+ readonly TSModuleDeclaration: readonly ["id", "body"];
1970
+ readonly TSModuleBlock: readonly ["body"];
1971
+ readonly TSImportEqualsDeclaration: readonly ["id", "moduleReference"];
1972
+ readonly TSExternalModuleReference: readonly ["expression"];
1973
+ readonly TSExportAssignment: readonly ["expression"];
1974
+ readonly TSNamespaceExportDeclaration: readonly ["id"];
1975
+ readonly TSDeclareFunction: readonly ["id", "typeParameters", "params", "returnType"];
1976
+ readonly TSDeclareMethod: readonly ["typeParameters", "params", "returnType"];
1977
+ readonly TSParameterProperty: readonly ["parameter"];
1978
+ readonly TSAsExpression: readonly ["expression", "typeAnnotation"];
1979
+ readonly TSSatisfiesExpression: readonly ["expression", "typeAnnotation"];
1980
+ readonly TSTypeAssertion: readonly ["typeAnnotation", "expression"];
1981
+ readonly TSNonNullExpression: readonly ["expression"];
1982
+ readonly TSInstantiationExpression: readonly ["expression", "typeArguments"];
1983
+ };
1984
+
1985
+ /**
1986
+ * Return it from `enter` or `leave` to end the walk: no further `enter` or
1987
+ * `leave` calls, including `leave` on the node's ancestors.
1988
+ */
1989
+ export declare const STOP: unique symbol;
1990
+
1991
+ /**
1992
+ * Return it from `enter` to skip the node's children; `leave` is still
1993
+ * called on the node.
1994
+ */
1995
+ export declare const SKIP: unique symbol;
1996
+
1997
+ /** The callbacks {@link walk} calls for each node. */
1998
+ export interface Visitor {
1999
+ /**
2000
+ * Called before the node's children. Return {@link SKIP} to skip them;
2001
+ * `leave` is still called, so the two stay paired. Return {@link STOP} to
2002
+ * end the walk. Return another node to put it in this one's place: `walk`
2003
+ * writes it to `parent[key]` (or `parent[key][index]`), then calls `enter`
2004
+ * on it and visits its children instead. Any other value, `false`
2005
+ * included, is ignored, so `(node) => node.type === "Component" &&
2006
+ * names.add(node.name)` visits every node.
2007
+ */
2008
+ enter?(node: AST.SvelteNode, parent: AST.SvelteNode | null, key: string | null, index: number | null): unknown;
2009
+ /** Called after the node's children. Return {@link STOP} to end the walk. */
2010
+ leave?(node: AST.SvelteNode, parent: AST.SvelteNode | null, key: string | null, index: number | null): unknown;
2011
+ }
2012
+
2013
+ /**
2014
+ * Visits `node` and its descendants depth-first, in source order, calling
2015
+ * `visitor.enter` before a node's children and `visitor.leave` after them.
2016
+ * `parent[key]` is the node, or `parent[key][index]` when the field is an
2017
+ * array; all three are `null` for `node` itself.
2018
+ */
2019
+ export declare function walk(node: AST.SvelteNode, visitor: Visitor): void;
2020
+
2021
+ /**
2022
+ * The `Identifier` nodes a pattern binds, in source order: `a`, `c`, `d`,
2023
+ * `e` and `f` in `{ a, b: [c, ...d], e = 1, ...f }`. Not the property
2024
+ * keys, defaults or type annotations. A member expression, which an
2025
+ * assignment's pattern can hold, as in `[a.b] = c`, binds nothing, so it
2026
+ * yields no identifiers, as in svelte's `extract_identifiers`. Also takes
2027
+ * a function's params as they are, parameter properties included, and an
2028
+ * assignment's `left`, where `a!`, `a as T`, `a satisfies T` and `<T>a`
2029
+ * yield `a`.
2030
+ */
2031
+ export declare function extractIdentifiers(pattern: Pattern | TSParameterProperty | AssignmentExpression["left"]): Identifier[];
2032
+
2033
+ /**
2034
+ * Whether `node` is an `Identifier` that names a binding in the value
2035
+ * namespace, where it's declared or where it's used, given its `parent`
2036
+ * from `walk`. `false` for a property, method or label name, the
2037
+ * renamed side of an import or export specifier, `import.meta`'s and
2038
+ * `new.target`'s names, an import attribute's key, and every name in a
2039
+ * type. The check svelte's analyzer makes, from the `is-reference` package,
2040
+ * plus TypeScript: an `Identifier` whose parent is a TypeScript node is a
2041
+ * reference only as the expression of `as`, `satisfies`, `<T>x`, `x!`,
2042
+ * `f<T>` or `export =`, an enum member's initializer, a parameter
2043
+ * property, an enum's name, or the name or target of `import a = b`.
2044
+ */
2045
+ export declare function isReference(node: AST.SvelteNode, parent: AST.SvelteNode | null): boolean;