sveast 0.0.0 → 0.2.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 ADDED
@@ -0,0 +1,1686 @@
1
+ /**
2
+ * Parses a Svelte component into svelte's modern AST, the same as
3
+ * `parse(source, { modern: true })` from svelte/compiler. From svelte's
4
+ * `Parser` constructor (`phases/1-parse/index.js`).
5
+ *
6
+ * Throws a {@link ParseError} on a syntax error.
7
+ */
8
+ export declare function parse(source: string, options?: ParseOptions): AST.Root;
9
+
10
+ /**
11
+ * Options for {@link parse}. The defaults give svelte's own output, minus
12
+ * `loc` and `name_loc`.
13
+ */
14
+ export interface ParseOptions {
15
+ /**
16
+ * Add `loc` (line/column) to script and expression nodes, and `name_loc`
17
+ * to elements, attributes and directives, as svelte does. Off by default:
18
+ * it makes parsing slower and the AST larger.
19
+ */
20
+ loc?: boolean;
21
+ /**
22
+ * Parse `<style>` into rules and selectors (`css.children`). With `false`,
23
+ * `css` still has its `start`, `end` and `content`, but `children` and
24
+ * `comments` are empty and CSS syntax errors aren't reported. Default `true`.
25
+ */
26
+ css?: boolean;
27
+ }
28
+
29
+ export interface BaseNodeWithoutComments {
30
+ type: string;
31
+ start: number;
32
+ end: number;
33
+ loc?: SourceLocation | null | undefined;
34
+ range?: [number, number] | undefined;
35
+ }
36
+
37
+ export interface BaseNode extends BaseNodeWithoutComments {
38
+ leadingComments?: Comment[] | undefined;
39
+ trailingComments?: Comment[] | undefined;
40
+ }
41
+
42
+ export interface NodeMap {
43
+ AssignmentProperty: AssignmentProperty;
44
+ CatchClause: CatchClause;
45
+ Class: Class;
46
+ ClassBody: ClassBody;
47
+ Expression: Expression;
48
+ Function: Function;
49
+ Identifier: Identifier;
50
+ Literal: Literal;
51
+ MethodDefinition: MethodDefinition;
52
+ ModuleDeclaration: ModuleDeclaration;
53
+ ModuleSpecifier: ModuleSpecifier;
54
+ Pattern: Pattern;
55
+ PrivateIdentifier: PrivateIdentifier;
56
+ Program: Program;
57
+ Property: Property;
58
+ PropertyDefinition: PropertyDefinition;
59
+ SpreadElement: SpreadElement;
60
+ Statement: Statement;
61
+ Super: Super;
62
+ SwitchCase: SwitchCase;
63
+ TemplateElement: TemplateElement;
64
+ VariableDeclarator: VariableDeclarator;
65
+ ImportAttribute: ImportAttribute;
66
+ TSNode: TSNode;
67
+ }
68
+
69
+ export type Node = NodeMap[keyof NodeMap];
70
+
71
+ export interface Comment extends BaseNodeWithoutComments {
72
+ type: "Line" | "Block";
73
+ value: string;
74
+ }
75
+
76
+ export interface SourceLocation {
77
+ source?: string | null | undefined;
78
+ start: Position;
79
+ end: Position;
80
+ }
81
+
82
+ export interface Position {
83
+ /** >= 1 */
84
+ line: number;
85
+ /** >= 0 */
86
+ column: number;
87
+ }
88
+
89
+ export interface Program extends Omit<BaseNode, "leadingComments"> {
90
+ type: "Program";
91
+ sourceType: "script" | "module";
92
+ body: Array<Directive | Statement | ModuleDeclaration>;
93
+ comments?: Comment[] | undefined;
94
+ /** In a component's `<script>`, an HTML comment right before the tag becomes `{ type: "Line", value }`, without offsets, as in svelte. */
95
+ leadingComments?: Array<Comment | {
96
+ type: "Line";
97
+ value: string;
98
+ }> | undefined;
99
+ }
100
+
101
+ export interface Directive extends BaseNode {
102
+ type: "ExpressionStatement";
103
+ expression: Literal;
104
+ directive: string;
105
+ }
106
+
107
+ export interface BaseFunction extends BaseNode, TSFunctionFields {
108
+ params: Array<Pattern | TSParameterProperty>;
109
+ generator?: boolean | undefined;
110
+ async?: boolean | undefined;
111
+ body: BlockStatement | Expression;
112
+ }
113
+
114
+ export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
115
+
116
+ export type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
117
+
118
+ export interface BaseStatement extends BaseNode {
119
+ }
120
+
121
+ export interface EmptyStatement extends BaseStatement {
122
+ type: "EmptyStatement";
123
+ }
124
+
125
+ export interface BlockStatement extends BaseStatement {
126
+ type: "BlockStatement";
127
+ body: Statement[];
128
+ innerComments?: Comment[] | undefined;
129
+ }
130
+
131
+ export interface StaticBlock extends Omit<BlockStatement, "type"> {
132
+ type: "StaticBlock";
133
+ }
134
+
135
+ export interface ExpressionStatement extends BaseStatement {
136
+ type: "ExpressionStatement";
137
+ expression: Expression;
138
+ }
139
+
140
+ export interface IfStatement extends BaseStatement {
141
+ type: "IfStatement";
142
+ test: Expression;
143
+ consequent: Statement;
144
+ alternate?: Statement | null | undefined;
145
+ }
146
+
147
+ export interface LabeledStatement extends BaseStatement {
148
+ type: "LabeledStatement";
149
+ label: Identifier;
150
+ body: Statement;
151
+ }
152
+
153
+ export interface BreakStatement extends BaseStatement {
154
+ type: "BreakStatement";
155
+ label?: Identifier | null | undefined;
156
+ }
157
+
158
+ export interface ContinueStatement extends BaseStatement {
159
+ type: "ContinueStatement";
160
+ label?: Identifier | null | undefined;
161
+ }
162
+
163
+ export interface WithStatement extends BaseStatement {
164
+ type: "WithStatement";
165
+ object: Expression;
166
+ body: Statement;
167
+ }
168
+
169
+ export interface SwitchStatement extends BaseStatement {
170
+ type: "SwitchStatement";
171
+ discriminant: Expression;
172
+ cases: SwitchCase[];
173
+ }
174
+
175
+ export interface ReturnStatement extends BaseStatement {
176
+ type: "ReturnStatement";
177
+ argument?: Expression | null | undefined;
178
+ }
179
+
180
+ export interface ThrowStatement extends BaseStatement {
181
+ type: "ThrowStatement";
182
+ argument: Expression;
183
+ }
184
+
185
+ export interface TryStatement extends BaseStatement {
186
+ type: "TryStatement";
187
+ block: BlockStatement;
188
+ handler?: CatchClause | null | undefined;
189
+ finalizer?: BlockStatement | null | undefined;
190
+ }
191
+
192
+ export interface WhileStatement extends BaseStatement {
193
+ type: "WhileStatement";
194
+ test: Expression;
195
+ body: Statement;
196
+ }
197
+
198
+ export interface DoWhileStatement extends BaseStatement {
199
+ type: "DoWhileStatement";
200
+ body: Statement;
201
+ test: Expression;
202
+ }
203
+
204
+ export interface ForStatement extends BaseStatement {
205
+ type: "ForStatement";
206
+ init?: VariableDeclaration | Expression | null | undefined;
207
+ test?: Expression | null | undefined;
208
+ update?: Expression | null | undefined;
209
+ body: Statement;
210
+ }
211
+
212
+ export interface BaseForXStatement extends BaseStatement {
213
+ left: VariableDeclaration | Pattern;
214
+ right: Expression;
215
+ body: Statement;
216
+ }
217
+
218
+ export interface ForInStatement extends BaseForXStatement {
219
+ type: "ForInStatement";
220
+ }
221
+
222
+ export interface DebuggerStatement extends BaseStatement {
223
+ type: "DebuggerStatement";
224
+ }
225
+
226
+ export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | TSDeclaration;
227
+
228
+ export interface BaseDeclaration extends BaseStatement {
229
+ }
230
+
231
+ export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
232
+ type: "FunctionDeclaration";
233
+ /** It is null when a function declaration is a part of the `export default function` statement */
234
+ id: Identifier | null;
235
+ body: BlockStatement;
236
+ expression: false;
237
+ }
238
+
239
+ export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
240
+ id: Identifier;
241
+ }
242
+
243
+ export interface VariableDeclaration extends BaseDeclaration {
244
+ type: "VariableDeclaration";
245
+ declarations: VariableDeclarator[];
246
+ kind: "var" | "let" | "const" | "using" | "await using";
247
+ declare?: boolean;
248
+ }
249
+
250
+ export interface VariableDeclarator extends BaseNode {
251
+ type: "VariableDeclarator";
252
+ id: Pattern;
253
+ init?: Expression | null | undefined;
254
+ definite?: boolean;
255
+ }
256
+
257
+ export interface ExpressionMap {
258
+ ArrayExpression: ArrayExpression;
259
+ ArrowFunctionExpression: ArrowFunctionExpression;
260
+ AssignmentExpression: AssignmentExpression;
261
+ AwaitExpression: AwaitExpression;
262
+ BinaryExpression: BinaryExpression;
263
+ CallExpression: CallExpression;
264
+ ChainExpression: ChainExpression;
265
+ ClassExpression: ClassExpression;
266
+ ConditionalExpression: ConditionalExpression;
267
+ FunctionExpression: FunctionExpression;
268
+ Identifier: Identifier;
269
+ ImportExpression: ImportExpression;
270
+ Literal: Literal;
271
+ LogicalExpression: LogicalExpression;
272
+ MemberExpression: MemberExpression;
273
+ MetaProperty: MetaProperty;
274
+ NewExpression: NewExpression;
275
+ ObjectExpression: ObjectExpression;
276
+ SequenceExpression: SequenceExpression;
277
+ TaggedTemplateExpression: TaggedTemplateExpression;
278
+ TemplateLiteral: TemplateLiteral;
279
+ ThisExpression: ThisExpression;
280
+ UnaryExpression: UnaryExpression;
281
+ UpdateExpression: UpdateExpression;
282
+ YieldExpression: YieldExpression;
283
+ TSExpression: TSExpression;
284
+ }
285
+
286
+ export type Expression = ExpressionMap[keyof ExpressionMap];
287
+
288
+ export interface BaseExpression extends BaseNode {
289
+ }
290
+
291
+ export type ChainElement = SimpleCallExpression | MemberExpression;
292
+
293
+ export interface ChainExpression extends BaseExpression {
294
+ type: "ChainExpression";
295
+ expression: ChainElement;
296
+ }
297
+
298
+ export interface ThisExpression extends BaseExpression {
299
+ type: "ThisExpression";
300
+ }
301
+
302
+ export interface ArrayExpression extends BaseExpression {
303
+ type: "ArrayExpression";
304
+ elements: Array<Expression | SpreadElement | null>;
305
+ }
306
+
307
+ export interface ObjectExpression extends BaseExpression {
308
+ type: "ObjectExpression";
309
+ properties: Array<Property | SpreadElement>;
310
+ }
311
+
312
+ export interface PrivateIdentifier extends BaseNode {
313
+ type: "PrivateIdentifier";
314
+ name: string;
315
+ }
316
+
317
+ export interface Property extends BaseNode {
318
+ type: "Property";
319
+ key: Expression;
320
+ value: Expression | Pattern;
321
+ kind: "init" | "get" | "set";
322
+ method: boolean;
323
+ shorthand: boolean;
324
+ computed: boolean;
325
+ decorators?: Decorator[];
326
+ }
327
+
328
+ export interface PropertyDefinition extends BaseNode, TSClassMemberFields {
329
+ type: "PropertyDefinition";
330
+ key: Expression | PrivateIdentifier;
331
+ value?: Expression | null | undefined;
332
+ computed: boolean;
333
+ static: boolean;
334
+ typeAnnotation?: TSTypeAnnotation;
335
+ definite?: boolean;
336
+ }
337
+
338
+ export interface FunctionExpression extends BaseFunction, BaseExpression {
339
+ id?: Identifier | null | undefined;
340
+ type: "FunctionExpression";
341
+ body: BlockStatement;
342
+ expression: false;
343
+ }
344
+
345
+ export interface SequenceExpression extends BaseExpression {
346
+ type: "SequenceExpression";
347
+ expressions: Expression[];
348
+ }
349
+
350
+ export interface UnaryExpression extends BaseExpression {
351
+ type: "UnaryExpression";
352
+ operator: UnaryOperator;
353
+ prefix: true;
354
+ argument: Expression;
355
+ }
356
+
357
+ export interface BinaryExpression extends BaseExpression {
358
+ type: "BinaryExpression";
359
+ operator: BinaryOperator;
360
+ left: Expression | PrivateIdentifier;
361
+ right: Expression;
362
+ }
363
+
364
+ export interface AssignmentExpression extends BaseExpression {
365
+ type: "AssignmentExpression";
366
+ operator: AssignmentOperator;
367
+ left: Pattern | MemberExpression | TSAsExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
368
+ right: Expression;
369
+ }
370
+
371
+ export interface UpdateExpression extends BaseExpression {
372
+ type: "UpdateExpression";
373
+ operator: UpdateOperator;
374
+ argument: Expression;
375
+ prefix: boolean;
376
+ }
377
+
378
+ export interface LogicalExpression extends BaseExpression {
379
+ type: "LogicalExpression";
380
+ operator: LogicalOperator;
381
+ left: Expression;
382
+ right: Expression;
383
+ }
384
+
385
+ export interface ConditionalExpression extends BaseExpression {
386
+ type: "ConditionalExpression";
387
+ test: Expression;
388
+ alternate: Expression;
389
+ consequent: Expression;
390
+ }
391
+
392
+ export interface BaseCallExpression extends BaseExpression {
393
+ callee: Expression | Super;
394
+ arguments: Array<Expression | SpreadElement>;
395
+ typeArguments?: TSTypeParameterInstantiation;
396
+ }
397
+
398
+ export type CallExpression = SimpleCallExpression | NewExpression;
399
+
400
+ export interface SimpleCallExpression extends BaseCallExpression {
401
+ type: "CallExpression";
402
+ /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
403
+ optional?: boolean;
404
+ }
405
+
406
+ export interface NewExpression extends BaseCallExpression {
407
+ type: "NewExpression";
408
+ }
409
+
410
+ export interface MemberExpression extends BaseExpression, BasePattern {
411
+ type: "MemberExpression";
412
+ object: Expression | Super;
413
+ property: Expression | PrivateIdentifier;
414
+ computed: boolean;
415
+ /** Absent in a decorator, and on a call with type arguments, as in acorn-typescript. */
416
+ optional?: boolean;
417
+ }
418
+
419
+ export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
420
+
421
+ export interface BasePattern extends BaseNode {
422
+ }
423
+
424
+ export interface SwitchCase extends BaseNode {
425
+ type: "SwitchCase";
426
+ test?: Expression | null | undefined;
427
+ consequent: Statement[];
428
+ }
429
+
430
+ export interface CatchClause extends BaseNode {
431
+ type: "CatchClause";
432
+ param: Pattern | null;
433
+ body: BlockStatement;
434
+ }
435
+
436
+ export interface Identifier extends BaseNode, BaseExpression, BasePattern, TSBindingFields {
437
+ type: "Identifier";
438
+ name: string;
439
+ }
440
+
441
+ export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
442
+
443
+ export interface SimpleLiteral extends BaseNode, BaseExpression {
444
+ type: "Literal";
445
+ value: string | boolean | number | null;
446
+ raw?: string | undefined;
447
+ }
448
+
449
+ export interface RegExpLiteral extends BaseNode, BaseExpression {
450
+ type: "Literal";
451
+ value?: RegExp | null | undefined;
452
+ regex: {
453
+ pattern: string;
454
+ flags: string;
455
+ };
456
+ raw?: string | undefined;
457
+ }
458
+
459
+ export interface BigIntLiteral extends BaseNode, BaseExpression {
460
+ type: "Literal";
461
+ value?: bigint | null | undefined;
462
+ bigint: string;
463
+ raw?: string | undefined;
464
+ }
465
+
466
+ export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
467
+
468
+ export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
469
+
470
+ export type LogicalOperator = "||" | "&&" | "??";
471
+
472
+ export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
473
+
474
+ export type UpdateOperator = "++" | "--";
475
+
476
+ export interface ForOfStatement extends BaseForXStatement {
477
+ type: "ForOfStatement";
478
+ await: boolean;
479
+ }
480
+
481
+ export interface Super extends BaseNode {
482
+ type: "Super";
483
+ }
484
+
485
+ export interface SpreadElement extends BaseNode {
486
+ type: "SpreadElement";
487
+ argument: Expression;
488
+ }
489
+
490
+ export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
491
+ type: "ArrowFunctionExpression";
492
+ expression: boolean;
493
+ body: BlockStatement | Expression;
494
+ id: null;
495
+ }
496
+
497
+ export interface YieldExpression extends BaseExpression {
498
+ type: "YieldExpression";
499
+ argument?: Expression | null | undefined;
500
+ delegate: boolean;
501
+ }
502
+
503
+ export interface TemplateLiteral extends BaseExpression {
504
+ type: "TemplateLiteral";
505
+ quasis: TemplateElement[];
506
+ expressions: Expression[];
507
+ }
508
+
509
+ export interface TaggedTemplateExpression extends BaseExpression {
510
+ type: "TaggedTemplateExpression";
511
+ tag: Expression;
512
+ quasi: TemplateLiteral;
513
+ typeArguments?: TSTypeParameterInstantiation;
514
+ }
515
+
516
+ export interface TemplateElement extends BaseNode {
517
+ type: "TemplateElement";
518
+ tail: boolean;
519
+ value: {
520
+ /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
521
+ cooked?: string | null | undefined;
522
+ raw: string;
523
+ };
524
+ }
525
+
526
+ export interface AssignmentProperty extends Property {
527
+ value: Pattern;
528
+ kind: "init";
529
+ method: boolean;
530
+ }
531
+
532
+ export interface ObjectPattern extends BasePattern, TSBindingFields {
533
+ type: "ObjectPattern";
534
+ properties: Array<AssignmentProperty | RestElement>;
535
+ }
536
+
537
+ export interface ArrayPattern extends BasePattern, TSBindingFields {
538
+ type: "ArrayPattern";
539
+ elements: Array<Pattern | null>;
540
+ }
541
+
542
+ export interface RestElement extends BasePattern, TSBindingFields {
543
+ type: "RestElement";
544
+ argument: Pattern;
545
+ }
546
+
547
+ export interface AssignmentPattern extends BasePattern {
548
+ type: "AssignmentPattern";
549
+ left: Pattern;
550
+ right: Expression;
551
+ decorators?: Decorator[];
552
+ }
553
+
554
+ export type Class = ClassDeclaration | ClassExpression;
555
+
556
+ export interface BaseClass extends BaseNode, TSClassFields {
557
+ superClass?: Expression | null | undefined;
558
+ body: ClassBody;
559
+ }
560
+
561
+ export interface ClassBody extends BaseNode {
562
+ type: "ClassBody";
563
+ body: Array<MethodDefinition | PropertyDefinition | StaticBlock | TSIndexSignature>;
564
+ }
565
+
566
+ export interface MethodDefinition extends BaseNode, TSClassMemberFields {
567
+ type: "MethodDefinition";
568
+ key: Expression | PrivateIdentifier;
569
+ value: FunctionExpression | TSDeclareMethod;
570
+ kind: "constructor" | "method" | "get" | "set";
571
+ computed: boolean;
572
+ static: boolean;
573
+ typeParameters?: TSTypeParameterDeclaration;
574
+ }
575
+
576
+ export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
577
+ type: "ClassDeclaration";
578
+ /** It is null when a class declaration is a part of the `export default class` statement */
579
+ id: Identifier | null;
580
+ }
581
+
582
+ export interface ClassDeclaration extends MaybeNamedClassDeclaration {
583
+ id: Identifier;
584
+ }
585
+
586
+ export interface ClassExpression extends BaseClass, BaseExpression {
587
+ type: "ClassExpression";
588
+ id?: Identifier | null | undefined;
589
+ }
590
+
591
+ export interface MetaProperty extends BaseExpression {
592
+ type: "MetaProperty";
593
+ meta: Identifier;
594
+ property: Identifier;
595
+ }
596
+
597
+ export type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | TSModuleDeclarationStatement;
598
+
599
+ export interface BaseModuleDeclaration extends BaseNode {
600
+ }
601
+
602
+ export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
603
+
604
+ export interface BaseModuleSpecifier extends BaseNode {
605
+ local: Identifier;
606
+ }
607
+
608
+ export interface ImportDeclaration extends BaseModuleDeclaration {
609
+ type: "ImportDeclaration";
610
+ specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
611
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
612
+ attributes?: ImportAttribute[] | undefined;
613
+ source: Literal;
614
+ importKind?: "type" | "value";
615
+ }
616
+
617
+ export interface ImportSpecifier extends BaseModuleSpecifier {
618
+ type: "ImportSpecifier";
619
+ imported: Identifier | Literal;
620
+ importKind?: "type" | "value";
621
+ }
622
+
623
+ export interface ImportAttribute extends BaseNode {
624
+ type: "ImportAttribute";
625
+ key: Identifier | Literal;
626
+ value: Literal;
627
+ }
628
+
629
+ export interface ImportExpression extends BaseExpression {
630
+ type: "ImportExpression";
631
+ source: Expression;
632
+ options?: Expression | null | undefined;
633
+ /** The import attributes, with `typescript: true`; `options` otherwise. */
634
+ arguments?: Expression[];
635
+ }
636
+
637
+ export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
638
+ type: "ImportDefaultSpecifier";
639
+ }
640
+
641
+ export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
642
+ type: "ImportNamespaceSpecifier";
643
+ }
644
+
645
+ export interface ExportNamedDeclaration extends BaseModuleDeclaration {
646
+ type: "ExportNamedDeclaration";
647
+ declaration?: Declaration | null | undefined;
648
+ specifiers: ExportSpecifier[];
649
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
650
+ attributes?: ImportAttribute[] | undefined;
651
+ source?: Literal | null | undefined;
652
+ exportKind?: "type" | "value";
653
+ }
654
+
655
+ export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
656
+ type: "ExportSpecifier";
657
+ local: Identifier | Literal;
658
+ exported: Identifier | Literal;
659
+ exportKind?: "type" | "value";
660
+ }
661
+
662
+ export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
663
+ type: "ExportDefaultDeclaration";
664
+ declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression | TSDeclareFunction | TSInterfaceDeclaration;
665
+ exportKind?: "type" | "value";
666
+ }
667
+
668
+ export interface ExportAllDeclaration extends BaseModuleDeclaration {
669
+ type: "ExportAllDeclaration";
670
+ exported: Identifier | Literal | null;
671
+ /** Absent with `typescript: true` unless there's a `with` clause, as in acorn-typescript. */
672
+ attributes?: ImportAttribute[] | undefined;
673
+ source: Literal;
674
+ exportKind?: "type" | "value";
675
+ }
676
+
677
+ export interface AwaitExpression extends BaseExpression {
678
+ type: "AwaitExpression";
679
+ argument: Expression;
680
+ }
681
+
682
+ 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;
683
+
684
+ /** Declarations; in estree's `Declaration` union. */
685
+ export type TSDeclaration = TSDeclareFunction | TSEnumDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSTypeAliasDeclaration;
686
+
687
+ /** Module-level statements; in estree's `ModuleDeclaration` union. */
688
+ export type TSModuleDeclarationStatement = TSExportAssignment | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
689
+
690
+ /** Expressions; in estree's `Expression` union. */
691
+ export type TSExpression = TSAsExpression | TSInstantiationExpression | TSNonNullExpression | TSSatisfiesExpression | TSTypeAssertion;
692
+
693
+ 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;
694
+
695
+ export type TypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature | TSMethodSignature | TSPropertySignature;
696
+
697
+ export type EntityName = Identifier | TSQualifiedName;
698
+
699
+ export type Accessibility = "public" | "private" | "protected";
700
+
701
+ /** A parameter of a function type, method signature or declared function. */
702
+ export type SignatureParameter = Identifier | ObjectPattern | ArrayPattern | RestElement;
703
+
704
+ /** Fields the plugin adds to `Identifier`, `ObjectPattern`, `ArrayPattern` and `RestElement`. */
705
+ export interface TSBindingFields {
706
+ typeAnnotation?: TSTypeAnnotation | undefined;
707
+ /** `a?` in a parameter list. */
708
+ optional?: boolean;
709
+ decorators?: Decorator[];
710
+ }
711
+
712
+ /** Fields the plugin adds to functions. */
713
+ export interface TSFunctionFields {
714
+ typeParameters?: TSTypeParameterDeclaration;
715
+ returnType?: TSTypeAnnotation;
716
+ }
717
+
718
+ /** Fields the plugin adds to classes. */
719
+ export interface TSClassFields {
720
+ typeParameters?: TSTypeParameterDeclaration;
721
+ superTypeParameters?: TSTypeParameterInstantiation;
722
+ implements?: TSExpressionWithTypeArguments[];
723
+ abstract?: boolean;
724
+ declare?: boolean;
725
+ decorators?: Decorator[];
726
+ }
727
+
728
+ /** Modifiers the plugin adds to class members. */
729
+ export interface TSClassMemberFields {
730
+ accessibility?: Accessibility;
731
+ abstract?: boolean;
732
+ override?: boolean;
733
+ readonly?: boolean;
734
+ declare?: boolean;
735
+ accessor?: boolean;
736
+ optional?: boolean;
737
+ decorators?: Decorator[];
738
+ }
739
+
740
+ export interface Decorator extends BaseNode {
741
+ type: "Decorator";
742
+ expression: Expression;
743
+ }
744
+
745
+ export interface TSTypeAnnotation extends BaseNode {
746
+ type: "TSTypeAnnotation";
747
+ /** A predicate (`x is T`, `asserts x`) only in a return type. */
748
+ typeAnnotation: TypeNode | TSTypePredicate;
749
+ }
750
+
751
+ export interface TSTypePredicate extends BaseNode {
752
+ type: "TSTypePredicate";
753
+ parameterName: Identifier | TSThisType;
754
+ asserts: boolean;
755
+ /** `null` for `asserts x` without `is`. */
756
+ typeAnnotation: TSTypeAnnotation | null;
757
+ }
758
+
759
+ export interface TSAnyKeyword extends BaseNode {
760
+ type: "TSAnyKeyword";
761
+ }
762
+
763
+ export interface TSBigIntKeyword extends BaseNode {
764
+ type: "TSBigIntKeyword";
765
+ }
766
+
767
+ export interface TSBooleanKeyword extends BaseNode {
768
+ type: "TSBooleanKeyword";
769
+ }
770
+
771
+ export interface TSNeverKeyword extends BaseNode {
772
+ type: "TSNeverKeyword";
773
+ }
774
+
775
+ export interface TSNullKeyword extends BaseNode {
776
+ type: "TSNullKeyword";
777
+ }
778
+
779
+ export interface TSNumberKeyword extends BaseNode {
780
+ type: "TSNumberKeyword";
781
+ }
782
+
783
+ export interface TSObjectKeyword extends BaseNode {
784
+ type: "TSObjectKeyword";
785
+ }
786
+
787
+ export interface TSStringKeyword extends BaseNode {
788
+ type: "TSStringKeyword";
789
+ }
790
+
791
+ export interface TSSymbolKeyword extends BaseNode {
792
+ type: "TSSymbolKeyword";
793
+ }
794
+
795
+ export interface TSUndefinedKeyword extends BaseNode {
796
+ type: "TSUndefinedKeyword";
797
+ }
798
+
799
+ export interface TSUnknownKeyword extends BaseNode {
800
+ type: "TSUnknownKeyword";
801
+ }
802
+
803
+ export interface TSVoidKeyword extends BaseNode {
804
+ type: "TSVoidKeyword";
805
+ }
806
+
807
+ export interface TSThisType extends BaseNode {
808
+ type: "TSThisType";
809
+ }
810
+
811
+ export interface TSArrayType extends BaseNode {
812
+ type: "TSArrayType";
813
+ elementType: TypeNode;
814
+ }
815
+
816
+ export interface TSConditionalType extends BaseNode {
817
+ type: "TSConditionalType";
818
+ checkType: TypeNode;
819
+ extendsType: TypeNode;
820
+ trueType: TypeNode;
821
+ falseType: TypeNode;
822
+ }
823
+
824
+ export interface TSFunctionType extends BaseNode {
825
+ type: "TSFunctionType";
826
+ typeParameters?: TSTypeParameterDeclaration;
827
+ parameters: SignatureParameter[];
828
+ typeAnnotation: TSTypeAnnotation;
829
+ }
830
+
831
+ export interface TSConstructorType extends BaseNode {
832
+ type: "TSConstructorType";
833
+ abstract: boolean;
834
+ typeParameters?: TSTypeParameterDeclaration;
835
+ parameters: SignatureParameter[];
836
+ typeAnnotation: TSTypeAnnotation;
837
+ }
838
+
839
+ export interface TSImportType extends BaseNode {
840
+ type: "TSImportType";
841
+ argument: Literal;
842
+ qualifier?: EntityName;
843
+ typeArguments?: TSTypeParameterInstantiation;
844
+ }
845
+
846
+ export interface TSIndexedAccessType extends BaseNode {
847
+ type: "TSIndexedAccessType";
848
+ objectType: TypeNode;
849
+ indexType: TypeNode;
850
+ }
851
+
852
+ export interface TSInferType extends BaseNode {
853
+ type: "TSInferType";
854
+ typeParameter: TSTypeParameter;
855
+ }
856
+
857
+ export interface TSIntersectionType extends BaseNode {
858
+ type: "TSIntersectionType";
859
+ types: TypeNode[];
860
+ }
861
+
862
+ export interface TSUnionType extends BaseNode {
863
+ type: "TSUnionType";
864
+ types: TypeNode[];
865
+ }
866
+
867
+ export interface TSLiteralType extends BaseNode {
868
+ type: "TSLiteralType";
869
+ /** `UnaryExpression` for a negative number, e.g. `-1`. */
870
+ literal: Literal | UnaryExpression | TemplateLiteralType;
871
+ }
872
+
873
+ /** A template literal type, `` `prefix-${T}` ``: a `TemplateLiteral` whose expressions are types. */
874
+ export interface TemplateLiteralType extends BaseNode {
875
+ type: "TemplateLiteral";
876
+ quasis: TemplateElement[];
877
+ expressions: TypeNode[];
878
+ }
879
+
880
+ export interface TSMappedType extends BaseNode {
881
+ type: "TSMappedType";
882
+ readonly?: true | "+" | "-";
883
+ typeParameter: TSTypeParameter;
884
+ /** The `as` clause. */
885
+ nameType: TypeNode | null;
886
+ optional?: true | "+" | "-";
887
+ typeAnnotation?: TypeNode;
888
+ }
889
+
890
+ export interface TSParenthesizedType extends BaseNode {
891
+ type: "TSParenthesizedType";
892
+ typeAnnotation: TypeNode;
893
+ }
894
+
895
+ export interface TSTupleType extends BaseNode {
896
+ type: "TSTupleType";
897
+ elementTypes: Array<TypeNode | TSNamedTupleMember | TSOptionalType | TSRestType>;
898
+ }
899
+
900
+ export interface TSNamedTupleMember extends BaseNode {
901
+ type: "TSNamedTupleMember";
902
+ label: Identifier;
903
+ optional: boolean;
904
+ elementType: TypeNode;
905
+ }
906
+
907
+ export interface TSOptionalType extends BaseNode {
908
+ type: "TSOptionalType";
909
+ typeAnnotation: TypeNode;
910
+ }
911
+
912
+ export interface TSRestType extends BaseNode {
913
+ type: "TSRestType";
914
+ typeAnnotation: TypeNode | TSNamedTupleMember;
915
+ }
916
+
917
+ export interface TSTypeLiteral extends BaseNode {
918
+ type: "TSTypeLiteral";
919
+ members: TypeElement[];
920
+ }
921
+
922
+ export interface TSTypeOperator extends BaseNode {
923
+ type: "TSTypeOperator";
924
+ operator: "keyof" | "unique" | "readonly";
925
+ typeAnnotation: TypeNode;
926
+ }
927
+
928
+ export interface TSTypeQuery extends BaseNode {
929
+ type: "TSTypeQuery";
930
+ exprName: EntityName | TSImportType;
931
+ typeArguments?: TSTypeParameterInstantiation;
932
+ }
933
+
934
+ export interface TSTypeReference extends BaseNode {
935
+ type: "TSTypeReference";
936
+ typeName: EntityName;
937
+ typeArguments?: TSTypeParameterInstantiation;
938
+ }
939
+
940
+ export interface TSQualifiedName extends BaseNode {
941
+ type: "TSQualifiedName";
942
+ left: EntityName;
943
+ right: Identifier;
944
+ }
945
+
946
+ export interface TSTypeParameterDeclaration extends BaseNode {
947
+ type: "TSTypeParameterDeclaration";
948
+ params: TSTypeParameter[];
949
+ /** With a trailing comma, its offset. */
950
+ extra?: {
951
+ trailingComma: number;
952
+ };
953
+ }
954
+
955
+ export interface TSTypeParameter extends BaseNode {
956
+ type: "TSTypeParameter";
957
+ name: string;
958
+ constraint?: TypeNode;
959
+ default?: TypeNode;
960
+ const?: true;
961
+ in?: true;
962
+ out?: true;
963
+ }
964
+
965
+ export interface TSTypeParameterInstantiation extends BaseNode {
966
+ type: "TSTypeParameterInstantiation";
967
+ params: TypeNode[];
968
+ }
969
+
970
+ export interface TSPropertySignature extends BaseNode {
971
+ type: "TSPropertySignature";
972
+ key: Expression;
973
+ computed?: boolean;
974
+ optional?: boolean;
975
+ readonly?: boolean;
976
+ typeAnnotation?: TSTypeAnnotation;
977
+ }
978
+
979
+ export interface TSMethodSignature extends BaseNode {
980
+ type: "TSMethodSignature";
981
+ key: Expression;
982
+ computed?: boolean;
983
+ optional?: boolean;
984
+ kind: "method" | "get" | "set";
985
+ typeParameters?: TSTypeParameterDeclaration;
986
+ parameters: SignatureParameter[];
987
+ /** The return type. */
988
+ typeAnnotation?: TSTypeAnnotation;
989
+ }
990
+
991
+ /** In an interface, a type literal, or a class body (with the class member modifiers). */
992
+ export interface TSIndexSignature extends BaseNode, TSClassMemberFields {
993
+ type: "TSIndexSignature";
994
+ parameters: Identifier[];
995
+ typeAnnotation?: TSTypeAnnotation;
996
+ static?: boolean;
997
+ }
998
+
999
+ export interface TSCallSignatureDeclaration extends BaseNode {
1000
+ type: "TSCallSignatureDeclaration";
1001
+ typeParameters?: TSTypeParameterDeclaration;
1002
+ parameters: SignatureParameter[];
1003
+ typeAnnotation?: TSTypeAnnotation;
1004
+ }
1005
+
1006
+ export interface TSConstructSignatureDeclaration extends BaseNode {
1007
+ type: "TSConstructSignatureDeclaration";
1008
+ typeParameters?: TSTypeParameterDeclaration;
1009
+ parameters: SignatureParameter[];
1010
+ typeAnnotation?: TSTypeAnnotation;
1011
+ }
1012
+
1013
+ export interface TSInterfaceDeclaration extends BaseNode {
1014
+ type: "TSInterfaceDeclaration";
1015
+ id: Identifier;
1016
+ typeParameters?: TSTypeParameterDeclaration;
1017
+ extends?: TSExpressionWithTypeArguments[];
1018
+ body: TSInterfaceBody;
1019
+ declare?: boolean;
1020
+ }
1021
+
1022
+ export interface TSInterfaceBody extends BaseNode {
1023
+ type: "TSInterfaceBody";
1024
+ body: TypeElement[];
1025
+ }
1026
+
1027
+ /** An interface's `extends` or a class's `implements` entry. */
1028
+ export interface TSExpressionWithTypeArguments extends BaseNode {
1029
+ type: "TSExpressionWithTypeArguments";
1030
+ expression: EntityName;
1031
+ /** The type arguments, named `typeParameters` as in acorn-typescript. */
1032
+ typeParameters?: TSTypeParameterInstantiation;
1033
+ }
1034
+
1035
+ export interface TSTypeAliasDeclaration extends BaseNode {
1036
+ type: "TSTypeAliasDeclaration";
1037
+ id: Identifier;
1038
+ typeParameters?: TSTypeParameterDeclaration;
1039
+ typeAnnotation: TypeNode;
1040
+ declare?: boolean;
1041
+ }
1042
+
1043
+ export interface TSEnumDeclaration extends BaseNode {
1044
+ type: "TSEnumDeclaration";
1045
+ id: Identifier;
1046
+ members: TSEnumMember[];
1047
+ const?: boolean;
1048
+ declare?: boolean;
1049
+ }
1050
+
1051
+ export interface TSEnumMember extends BaseNode {
1052
+ type: "TSEnumMember";
1053
+ id: Identifier | Literal;
1054
+ initializer?: Expression;
1055
+ }
1056
+
1057
+ /** `namespace A {}`, `module "a" {}`, `declare global {}`; `namespace A.B {}` nests through `body`. */
1058
+ export interface TSModuleDeclaration extends BaseNode {
1059
+ type: "TSModuleDeclaration";
1060
+ id: Identifier | Literal;
1061
+ /** Absent for `declare module "a";`. */
1062
+ body?: TSModuleBlock | TSModuleDeclaration;
1063
+ declare?: boolean;
1064
+ global?: boolean;
1065
+ }
1066
+
1067
+ export interface TSModuleBlock extends BaseNode {
1068
+ type: "TSModuleBlock";
1069
+ body: Array<Statement | ModuleDeclaration>;
1070
+ }
1071
+
1072
+ /** A function declaration without a body: an overload or `declare function`. */
1073
+ export interface TSDeclareFunction extends BaseNode, TSFunctionFields {
1074
+ type: "TSDeclareFunction";
1075
+ /** `null` in `export default function (): void;`. */
1076
+ id: Identifier | null;
1077
+ params: Pattern[];
1078
+ expression: boolean;
1079
+ generator: boolean;
1080
+ async: boolean;
1081
+ declare?: boolean;
1082
+ }
1083
+
1084
+ /** A `MethodDefinition`'s value when the method has no body: an overload or an abstract method. */
1085
+ export interface TSDeclareMethod extends BaseNode, TSFunctionFields {
1086
+ type: "TSDeclareMethod";
1087
+ id: null;
1088
+ params: Array<Pattern | TSParameterProperty>;
1089
+ expression: boolean;
1090
+ generator: boolean;
1091
+ async: boolean;
1092
+ }
1093
+
1094
+ /** `constructor(private a: T)`: a constructor parameter with a modifier. */
1095
+ export interface TSParameterProperty extends BaseNode {
1096
+ type: "TSParameterProperty";
1097
+ accessibility?: Accessibility;
1098
+ readonly?: boolean;
1099
+ override?: boolean;
1100
+ parameter: Identifier | AssignmentPattern;
1101
+ }
1102
+
1103
+ /** `import a = require("a")`, `import a = B.C`, `export import a = B.C`. */
1104
+ export interface TSImportEqualsDeclaration extends BaseNode {
1105
+ type: "TSImportEqualsDeclaration";
1106
+ importKind: "type" | "value";
1107
+ isExport: boolean;
1108
+ id: Identifier;
1109
+ moduleReference: EntityName | TSExternalModuleReference;
1110
+ }
1111
+
1112
+ export interface TSExternalModuleReference extends BaseNode {
1113
+ type: "TSExternalModuleReference";
1114
+ expression: Literal;
1115
+ }
1116
+
1117
+ /** `export = a`. */
1118
+ export interface TSExportAssignment extends BaseNode {
1119
+ type: "TSExportAssignment";
1120
+ expression: Expression;
1121
+ }
1122
+
1123
+ /** `export as namespace A`. */
1124
+ export interface TSNamespaceExportDeclaration extends BaseNode {
1125
+ type: "TSNamespaceExportDeclaration";
1126
+ id: Identifier;
1127
+ }
1128
+
1129
+ export interface TSAsExpression extends BaseNode {
1130
+ type: "TSAsExpression";
1131
+ expression: Expression;
1132
+ typeAnnotation: TypeNode;
1133
+ }
1134
+
1135
+ export interface TSSatisfiesExpression extends BaseNode {
1136
+ type: "TSSatisfiesExpression";
1137
+ expression: Expression;
1138
+ typeAnnotation: TypeNode;
1139
+ }
1140
+
1141
+ /** `<T>a`. */
1142
+ export interface TSTypeAssertion extends BaseNode {
1143
+ type: "TSTypeAssertion";
1144
+ typeAnnotation: TypeNode;
1145
+ expression: Expression;
1146
+ }
1147
+
1148
+ export interface TSNonNullExpression extends BaseNode {
1149
+ type: "TSNonNullExpression";
1150
+ expression: Expression;
1151
+ }
1152
+
1153
+ /** `f<T>` without a call. */
1154
+ export interface TSInstantiationExpression extends BaseNode {
1155
+ type: "TSInstantiationExpression";
1156
+ expression: Expression;
1157
+ typeArguments: TSTypeParameterInstantiation;
1158
+ }
1159
+
1160
+ type Namespace = "html" | "svg" | "mathml";
1161
+
1162
+ export declare namespace AST {
1163
+ export interface BaseNode {
1164
+ type: string;
1165
+ start: number;
1166
+ end: number;
1167
+ }
1168
+ export interface Fragment {
1169
+ type: "Fragment";
1170
+ nodes: Array<Text | Tag | ElementLike | Block | Comment>;
1171
+ }
1172
+ export interface Root extends BaseNode {
1173
+ type: "Root";
1174
+ /**
1175
+ * Inline options provided by `<svelte:options>` — these override options passed to `compile(...)`
1176
+ */
1177
+ options: SvelteOptions | null;
1178
+ fragment: Fragment;
1179
+ /** The parsed `<style>` element, if exists */
1180
+ css: AST.CSS.StyleSheet | null;
1181
+ /** The parsed `<script>` element, if exists */
1182
+ instance?: Script;
1183
+ /** The parsed `<script module>` element, if exists */
1184
+ module?: Script;
1185
+ /** Comments found in <script> and {expressions} */
1186
+ comments: JSComment[];
1187
+ /** Always empty, as in svelte. */
1188
+ js: [];
1189
+ }
1190
+ export interface SvelteOptions {
1191
+ start: number;
1192
+ end: number;
1193
+ runes?: boolean;
1194
+ immutable?: boolean;
1195
+ accessors?: boolean;
1196
+ preserveWhitespace?: boolean;
1197
+ namespace?: Namespace;
1198
+ css?: "injected";
1199
+ customElement?: {
1200
+ tag?: string;
1201
+ shadow?: "open" | "none" | ObjectExpression | undefined;
1202
+ props?: Record<string, {
1203
+ attribute?: string;
1204
+ reflect?: boolean;
1205
+ type?: "Array" | "Boolean" | "Number" | "Object" | "String";
1206
+ }>;
1207
+ /**
1208
+ * Is of type
1209
+ * ```ts
1210
+ * (ceClass: new () => HTMLElement) => new () => HTMLElement
1211
+ * ```
1212
+ */
1213
+ extend?: ArrowFunctionExpression | Identifier;
1214
+ };
1215
+ attributes: Attribute[];
1216
+ }
1217
+ /** Static text */
1218
+ export interface Text extends BaseNode {
1219
+ type: "Text";
1220
+ /** Text with decoded HTML entities */
1221
+ data: string;
1222
+ /** The original text, with undecoded HTML entities */
1223
+ raw: string;
1224
+ }
1225
+ /** A (possibly reactive) template expression — `{...}` */
1226
+ export interface ExpressionTag extends BaseNode {
1227
+ type: "ExpressionTag";
1228
+ expression: Expression;
1229
+ }
1230
+ /** A (possibly reactive) HTML template expression — `{@html ...}` */
1231
+ export interface HtmlTag extends BaseNode {
1232
+ type: "HtmlTag";
1233
+ expression: Expression;
1234
+ }
1235
+ /** An HTML comment */
1236
+ export interface Comment extends BaseNode {
1237
+ type: "Comment";
1238
+ /** the contents of the comment */
1239
+ data: string;
1240
+ }
1241
+ /** A `{@const ...}` tag */
1242
+ export interface ConstTag extends BaseNode {
1243
+ type: "ConstTag";
1244
+ declaration: VariableDeclaration & {
1245
+ declarations: [VariableDeclarator & {
1246
+ id: Pattern;
1247
+ init: Expression;
1248
+ }];
1249
+ };
1250
+ }
1251
+ /** A `{let ...}` or `{const ...}` tag */
1252
+ export interface DeclarationTag extends BaseNode {
1253
+ type: "DeclarationTag";
1254
+ declaration: VariableDeclaration;
1255
+ }
1256
+ /** A `{@debug ...}` tag */
1257
+ export interface DebugTag extends BaseNode {
1258
+ type: "DebugTag";
1259
+ identifiers: Identifier[];
1260
+ }
1261
+ /** A `{@render foo(...)} tag */
1262
+ export interface RenderTag extends BaseNode {
1263
+ type: "RenderTag";
1264
+ expression: SimpleCallExpression | (ChainExpression & {
1265
+ expression: SimpleCallExpression;
1266
+ });
1267
+ }
1268
+ /** A `{@attach foo(...)} tag */
1269
+ export interface AttachTag extends BaseNode {
1270
+ type: "AttachTag";
1271
+ expression: Expression;
1272
+ }
1273
+ /** An `animate:` directive */
1274
+ export interface AnimateDirective extends BaseAttribute {
1275
+ type: "AnimateDirective";
1276
+ /** The 'x' in `animate:x` */
1277
+ name: string;
1278
+ /** The y in `animate:x={y}` */
1279
+ expression: null | Expression;
1280
+ /** Parsed for every directive, e.g. `use:x|y`; svelte's types declare it only on some. */
1281
+ modifiers: string[];
1282
+ }
1283
+ /** A `bind:` directive */
1284
+ export interface BindDirective extends BaseAttribute {
1285
+ type: "BindDirective";
1286
+ /** The 'x' in `bind:x` */
1287
+ name: string;
1288
+ /** The y in `bind:x={y}` */
1289
+ expression: Identifier | MemberExpression | SequenceExpression;
1290
+ /** Parsed for every directive, e.g. `use:x|y`; svelte's types declare it only on some. */
1291
+ modifiers: string[];
1292
+ }
1293
+ /** A `class:` directive */
1294
+ export interface ClassDirective extends BaseAttribute {
1295
+ type: "ClassDirective";
1296
+ /** The 'x' in `class:x` */
1297
+ name: "class";
1298
+ /** The 'y' in `class:x={y}`, or the `x` in `class:x` */
1299
+ expression: Expression;
1300
+ /** Parsed for every directive, e.g. `use:x|y`; svelte's types declare it only on some. */
1301
+ modifiers: string[];
1302
+ }
1303
+ /** A `let:` directive */
1304
+ export interface LetDirective extends BaseAttribute {
1305
+ type: "LetDirective";
1306
+ /** The 'x' in `let:x` */
1307
+ name: string;
1308
+ /** The 'y' in `let:x={y}` */
1309
+ expression: null | Identifier | ArrayExpression | ObjectExpression;
1310
+ /** Parsed for every directive, e.g. `use:x|y`; svelte's types declare it only on some. */
1311
+ modifiers: string[];
1312
+ }
1313
+ /** An `on:` directive */
1314
+ export interface OnDirective extends BaseAttribute {
1315
+ type: "OnDirective";
1316
+ /** The 'x' in `on:x` */
1317
+ name: string;
1318
+ /** The 'y' in `on:x={y}` */
1319
+ expression: null | Expression;
1320
+ modifiers: Array<"capture" | "nonpassive" | "once" | "passive" | "preventDefault" | "self" | "stopImmediatePropagation" | "stopPropagation" | "trusted">;
1321
+ }
1322
+ /** A `style:` directive */
1323
+ export interface StyleDirective extends BaseAttribute {
1324
+ type: "StyleDirective";
1325
+ /** The 'x' in `style:x` */
1326
+ name: string;
1327
+ /** The 'y' in `style:x={y}` */
1328
+ value: true | ExpressionTag | Array<ExpressionTag | Text>;
1329
+ modifiers: Array<"important">;
1330
+ }
1331
+ /** A `transition:`, `in:` or `out:` directive */
1332
+ export interface TransitionDirective extends BaseAttribute {
1333
+ type: "TransitionDirective";
1334
+ /** The 'x' in `transition:x` */
1335
+ name: string;
1336
+ /** The 'y' in `transition:x={y}` */
1337
+ expression: null | Expression;
1338
+ modifiers: Array<"local" | "global">;
1339
+ /** True if this is a `transition:` or `in:` directive */
1340
+ intro: boolean;
1341
+ /** True if this is a `transition:` or `out:` directive */
1342
+ outro: boolean;
1343
+ }
1344
+ /** A `use:` directive */
1345
+ export interface UseDirective extends BaseAttribute {
1346
+ type: "UseDirective";
1347
+ /** The 'x' in `use:x` */
1348
+ name: string;
1349
+ /** The 'y' in `use:x={y}` */
1350
+ expression: null | Expression;
1351
+ /** Parsed for every directive, e.g. `use:x|y`; svelte's types declare it only on some. */
1352
+ modifiers: string[];
1353
+ }
1354
+ export interface BaseElement extends BaseNode {
1355
+ name: string;
1356
+ /** Only with `parse(source, { loc: true })`. */
1357
+ name_loc?: SourceLocation;
1358
+ attributes: Array<Attribute | SpreadAttribute | Directive | AttachTag>;
1359
+ fragment: Fragment;
1360
+ }
1361
+ export interface Component extends BaseElement {
1362
+ type: "Component";
1363
+ }
1364
+ export interface TitleElement extends BaseElement {
1365
+ type: "TitleElement";
1366
+ name: "title";
1367
+ }
1368
+ export interface SlotElement extends BaseElement {
1369
+ type: "SlotElement";
1370
+ name: "slot";
1371
+ }
1372
+ export interface RegularElement extends BaseElement {
1373
+ type: "RegularElement";
1374
+ }
1375
+ export interface SvelteBody extends BaseElement {
1376
+ type: "SvelteBody";
1377
+ name: "svelte:body";
1378
+ }
1379
+ export interface SvelteComponent extends BaseElement {
1380
+ type: "SvelteComponent";
1381
+ name: "svelte:component";
1382
+ expression: Expression;
1383
+ }
1384
+ export interface SvelteDocument extends BaseElement {
1385
+ type: "SvelteDocument";
1386
+ name: "svelte:document";
1387
+ }
1388
+ export interface SvelteElement extends BaseElement {
1389
+ type: "SvelteElement";
1390
+ name: "svelte:element";
1391
+ tag: Expression;
1392
+ }
1393
+ export interface SvelteFragment extends BaseElement {
1394
+ type: "SvelteFragment";
1395
+ name: "svelte:fragment";
1396
+ }
1397
+ export interface SvelteBoundary extends BaseElement {
1398
+ type: "SvelteBoundary";
1399
+ name: "svelte:boundary";
1400
+ }
1401
+ export interface SvelteHead extends BaseElement {
1402
+ type: "SvelteHead";
1403
+ name: "svelte:head";
1404
+ }
1405
+ /** This is only an intermediate representation while parsing, it doesn't exist in the final AST */
1406
+ export interface SvelteOptionsRaw extends BaseElement {
1407
+ type: "SvelteOptions";
1408
+ name: "svelte:options";
1409
+ }
1410
+ export interface SvelteSelf extends BaseElement {
1411
+ type: "SvelteSelf";
1412
+ name: "svelte:self";
1413
+ }
1414
+ export interface SvelteWindow extends BaseElement {
1415
+ type: "SvelteWindow";
1416
+ name: "svelte:window";
1417
+ }
1418
+ /** An `{#each ...}` block */
1419
+ export interface EachBlock extends BaseNode {
1420
+ type: "EachBlock";
1421
+ expression: Expression;
1422
+ /** The `entry` in `{#each item as entry}`. `null` if `as` part is omitted */
1423
+ context: Pattern | null;
1424
+ body: Fragment;
1425
+ fallback?: Fragment;
1426
+ index?: string;
1427
+ key?: Expression;
1428
+ }
1429
+ /** An `{#if ...}` block */
1430
+ export interface IfBlock extends BaseNode {
1431
+ type: "IfBlock";
1432
+ elseif: boolean;
1433
+ test: Expression;
1434
+ consequent: Fragment;
1435
+ alternate: Fragment | null;
1436
+ }
1437
+ /** An `{#await ...}` block */
1438
+ export interface AwaitBlock extends BaseNode {
1439
+ type: "AwaitBlock";
1440
+ expression: Expression;
1441
+ /** The resolved value inside the `then` block */
1442
+ value: Pattern | null;
1443
+ /** The rejection reason inside the `catch` block */
1444
+ error: Pattern | null;
1445
+ pending: Fragment | null;
1446
+ then: Fragment | null;
1447
+ catch: Fragment | null;
1448
+ }
1449
+ export interface KeyBlock extends BaseNode {
1450
+ type: "KeyBlock";
1451
+ expression: Expression;
1452
+ fragment: Fragment;
1453
+ }
1454
+ export interface SnippetBlock extends BaseNode {
1455
+ type: "SnippetBlock";
1456
+ expression: Identifier;
1457
+ parameters: Pattern[];
1458
+ typeParams?: string;
1459
+ body: Fragment;
1460
+ }
1461
+ export interface BaseAttribute extends BaseNode {
1462
+ name: string;
1463
+ /** Only with `parse(source, { loc: true })`. */
1464
+ name_loc?: SourceLocation | null;
1465
+ }
1466
+ export interface Attribute extends BaseAttribute {
1467
+ type: "Attribute";
1468
+ /**
1469
+ * Quoted/string values are represented by an array, even if they contain a single expression like `"{x}"`
1470
+ */
1471
+ value: true | ExpressionTag | Array<Text | ExpressionTag>;
1472
+ }
1473
+ export interface SpreadAttribute extends BaseNode {
1474
+ type: "SpreadAttribute";
1475
+ expression: Expression;
1476
+ }
1477
+ export interface Script extends BaseNode {
1478
+ type: "Script";
1479
+ context: "default" | "module";
1480
+ content: Program;
1481
+ attributes: Attribute[];
1482
+ }
1483
+ export interface JSComment {
1484
+ type: "Line" | "Block";
1485
+ value: string;
1486
+ start: number;
1487
+ end: number;
1488
+ /** Only with `parse(source, { loc: true })`. */
1489
+ loc?: {
1490
+ start: {
1491
+ line: number;
1492
+ column: number;
1493
+ };
1494
+ end: {
1495
+ line: number;
1496
+ column: number;
1497
+ };
1498
+ };
1499
+ }
1500
+ export type AttributeLike = Attribute | SpreadAttribute | Directive;
1501
+ export type Directive = AST.AnimateDirective | AST.BindDirective | AST.ClassDirective | AST.LetDirective | AST.OnDirective | AST.StyleDirective | AST.TransitionDirective | AST.UseDirective;
1502
+ export type Block = AST.EachBlock | AST.IfBlock | AST.AwaitBlock | AST.KeyBlock | AST.SnippetBlock;
1503
+ 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;
1504
+ export type Tag = AST.AttachTag | AST.ConstTag | AST.DeclarationTag | AST.DebugTag | AST.ExpressionTag | AST.HtmlTag | AST.RenderTag;
1505
+ export type TemplateNode = AST.Root | AST.Text | Tag | ElementLike | AST.Attribute | AST.SpreadAttribute | Directive | AST.AttachTag | AST.Comment | Block;
1506
+ export type SvelteNode = Node | TemplateNode | AST.Fragment | _CSS.Node | Script;
1507
+ export type { _CSS as CSS };
1508
+ }
1509
+
1510
+ declare namespace _CSS {
1511
+ interface BaseNode {
1512
+ start: number;
1513
+ end: number;
1514
+ }
1515
+ interface StyleSheetBase extends BaseNode {
1516
+ children: Array<Atrule | Rule>;
1517
+ /** CSS comments in source order */
1518
+ comments: CSSComment[];
1519
+ }
1520
+ interface CSSComment extends BaseNode {
1521
+ type: "CSSComment";
1522
+ value: string;
1523
+ /** Character offset in a containing declaration value or at-rule prelude */
1524
+ position?: number;
1525
+ }
1526
+ interface StyleSheetFile extends StyleSheetBase {
1527
+ type: "StyleSheetFile";
1528
+ }
1529
+ interface StyleSheet extends StyleSheetBase {
1530
+ type: "StyleSheet";
1531
+ attributes: any[];
1532
+ content: {
1533
+ start: number;
1534
+ end: number;
1535
+ styles: string;
1536
+ /** Possible comment atop the style tag */
1537
+ comment: AST.Comment | null;
1538
+ };
1539
+ }
1540
+ interface Atrule extends BaseNode {
1541
+ type: "Atrule";
1542
+ name: string;
1543
+ prelude: string;
1544
+ block: Block | null;
1545
+ }
1546
+ interface Rule extends BaseNode {
1547
+ type: "Rule";
1548
+ prelude: SelectorList;
1549
+ block: Block;
1550
+ }
1551
+ /**
1552
+ * A list of selectors, e.g. `a, b, c {}`
1553
+ */
1554
+ interface SelectorList extends BaseNode {
1555
+ type: "SelectorList";
1556
+ /**
1557
+ * The `a`, `b` and `c` in `a, b, c {}`
1558
+ */
1559
+ children: ComplexSelector[];
1560
+ }
1561
+ /**
1562
+ * A complex selector, e.g. `a b c {}`
1563
+ */
1564
+ interface ComplexSelector extends BaseNode {
1565
+ type: "ComplexSelector";
1566
+ /**
1567
+ * The `a`, `b` and `c` in `a b c {}`
1568
+ */
1569
+ children: RelativeSelector[];
1570
+ }
1571
+ /**
1572
+ * A relative selector, e.g the `a` and `> b` in `a > b {}`
1573
+ */
1574
+ interface RelativeSelector extends BaseNode {
1575
+ type: "RelativeSelector";
1576
+ /**
1577
+ * In `a > b`, `> b` forms one relative selector, and `>` is the combinator. `null` for the first selector.
1578
+ */
1579
+ combinator: null | Combinator;
1580
+ /**
1581
+ * The `b:is(...)` in `> b:is(...)`
1582
+ */
1583
+ selectors: SimpleSelector[];
1584
+ }
1585
+ interface TypeSelector extends BaseNode {
1586
+ type: "TypeSelector";
1587
+ name: string;
1588
+ namespace?: string;
1589
+ }
1590
+ interface IdSelector extends BaseNode {
1591
+ type: "IdSelector";
1592
+ name: string;
1593
+ }
1594
+ interface ClassSelector extends BaseNode {
1595
+ type: "ClassSelector";
1596
+ name: string;
1597
+ }
1598
+ interface AttributeSelector extends BaseNode {
1599
+ type: "AttributeSelector";
1600
+ name: string;
1601
+ matcher: string | null;
1602
+ value: string | null;
1603
+ flags: string | null;
1604
+ }
1605
+ interface PseudoElementSelector extends BaseNode {
1606
+ type: "PseudoElementSelector";
1607
+ name: string;
1608
+ args?: SelectorList;
1609
+ }
1610
+ interface PseudoClassSelector extends BaseNode {
1611
+ type: "PseudoClassSelector";
1612
+ name: string;
1613
+ args: SelectorList | null;
1614
+ }
1615
+ interface Percentage extends BaseNode {
1616
+ type: "Percentage";
1617
+ value: string;
1618
+ }
1619
+ interface NestingSelector extends BaseNode {
1620
+ type: "NestingSelector";
1621
+ name: "&";
1622
+ }
1623
+ interface Nth extends BaseNode {
1624
+ type: "Nth";
1625
+ value: string;
1626
+ }
1627
+ type SimpleSelector = TypeSelector | IdSelector | ClassSelector | AttributeSelector | PseudoElementSelector | PseudoClassSelector | Percentage | Nth | NestingSelector;
1628
+ interface Combinator extends BaseNode {
1629
+ type: "Combinator";
1630
+ name: string;
1631
+ }
1632
+ interface Block extends BaseNode {
1633
+ type: "Block";
1634
+ children: Array<Declaration | Rule | Atrule>;
1635
+ }
1636
+ interface Declaration extends BaseNode {
1637
+ type: "Declaration";
1638
+ property: string;
1639
+ value: string;
1640
+ }
1641
+ type Node = StyleSheet | Rule | Atrule | SelectorList | Block | ComplexSelector | RelativeSelector | Combinator | SimpleSelector | Declaration;
1642
+ }
1643
+
1644
+ /**
1645
+ * Parses a JavaScript or TypeScript module, e.g. a `.ts` file a component
1646
+ * imports, into the same kind of AST as a component's `<script>`:
1647
+ * estree, TypeScript nodes as in `@sveltejs/acorn-typescript`, and
1648
+ * comments attached as `leadingComments`/`trailingComments`.
1649
+ *
1650
+ * Throws a {@link ParseError} (`js_parse_error`) on a syntax error.
1651
+ */
1652
+ export declare function parseModule(source: string, options?: {
1653
+ /** Parse TypeScript. Default `false`. */
1654
+ typescript?: boolean;
1655
+ /** Add `loc` (line/column) to every node. Default `false`. */
1656
+ loc?: boolean;
1657
+ }): Program;
1658
+
1659
+ type NodeLike = number | {
1660
+ start?: number;
1661
+ end?: number;
1662
+ } | null;
1663
+
1664
+ /**
1665
+ * Thrown for a syntax error. `code`, `message`, `position`, `start`, `end`
1666
+ * and `frame` are what svelte/compiler's `CompileError` has for the same
1667
+ * input.
1668
+ */
1669
+ export declare class ParseError extends Error {
1670
+ name: string;
1671
+ /** svelte's error code, e.g. `"expected_token"` or `"block_unclosed"`. */
1672
+ code: string;
1673
+ /** `[start, end]` offsets into the source. */
1674
+ position?: [number, number];
1675
+ start?: Location;
1676
+ end?: Location;
1677
+ /** A few lines of source around the error, with a `^` under it. */
1678
+ frame?: string;
1679
+ constructor(node: NodeLike, code: string, message: string);
1680
+ }
1681
+
1682
+ interface Location {
1683
+ line: number;
1684
+ column: number;
1685
+ character: number;
1686
+ }