@@ -65,11 +65,13 @@ export type SvelteNode =
65
65
| SvelteAwaitCatchBlock
66
66
| SvelteKeyBlock
67
67
| SvelteAttribute
68
+ | SvelteShorthandAttribute
68
69
| SvelteSpreadAttribute
69
70
| SvelteDirective
70
71
| SvelteHTMLComment
71
72
| SvelteReactiveStatement
72
73
74
+ /** Node of Svelte program root */
73
75
export interface SvelteProgram extends BaseNode {
74
76
type : "Program"
75
77
body : ( SvelteScriptElement | SvelteStyleElement | Child ) [ ]
@@ -79,27 +81,50 @@ export interface SvelteProgram extends BaseNode {
79
81
parent : null
80
82
}
81
83
84
+ /** Node of elements like HTML element. */
85
+ export type SvelteElement =
86
+ | SvelteHTMLElement
87
+ | SvelteComponentElement
88
+ | SvelteSpecialElement
82
89
type BaseSvelteElement = BaseNode
83
90
91
+ /** Node of `<script>` element. */
84
92
export interface SvelteScriptElement extends BaseSvelteElement {
85
93
type : "SvelteScriptElement"
86
94
name : SvelteName
87
- attributes : ( SvelteAttribute | SvelteSpreadAttribute | SvelteDirective ) [ ]
95
+ attributes : (
96
+ | SvelteAttribute
97
+ | SvelteShorthandAttribute
98
+ | SvelteSpreadAttribute
99
+ | SvelteDirective
100
+ ) [ ]
88
101
body : ESTree . Program [ "body" ]
89
102
parent : SvelteProgram
90
103
}
104
+ /** Node of `<style>` element. */
91
105
export interface SvelteStyleElement extends BaseSvelteElement {
92
106
type : "SvelteStyleElement"
93
107
name : SvelteName
94
- attributes : ( SvelteAttribute | SvelteSpreadAttribute | SvelteDirective ) [ ]
108
+ attributes : (
109
+ | SvelteAttribute
110
+ | SvelteShorthandAttribute
111
+ | SvelteSpreadAttribute
112
+ | SvelteDirective
113
+ ) [ ]
95
114
children : [ SvelteText ]
96
115
parent : SvelteProgram
97
116
}
117
+ /** Node of HTML element. */
98
118
export interface SvelteHTMLElement extends BaseSvelteElement {
99
119
type : "SvelteElement"
100
120
kind : "html"
101
121
name : SvelteName
102
- attributes : ( SvelteAttribute | SvelteSpreadAttribute | SvelteDirective ) [ ]
122
+ attributes : (
123
+ | SvelteAttribute
124
+ | SvelteShorthandAttribute
125
+ | SvelteSpreadAttribute
126
+ | SvelteDirective
127
+ ) [ ]
103
128
children : Child [ ]
104
129
parent :
105
130
| SvelteProgram
@@ -112,11 +137,17 @@ export interface SvelteHTMLElement extends BaseSvelteElement {
112
137
| SvelteAwaitCatchBlock
113
138
| SvelteKeyBlock
114
139
}
140
+ /** Node of Svelte component element. */
115
141
export interface SvelteComponentElement extends BaseSvelteElement {
116
142
type : "SvelteElement"
117
143
kind : "component"
118
144
name : ESTree . Identifier
119
- attributes : ( SvelteAttribute | SvelteSpreadAttribute | SvelteDirective ) [ ]
145
+ attributes : (
146
+ | SvelteAttribute
147
+ | SvelteShorthandAttribute
148
+ | SvelteSpreadAttribute
149
+ | SvelteDirective
150
+ ) [ ]
120
151
children : Child [ ]
121
152
parent :
122
153
| SvelteProgram
@@ -129,12 +160,14 @@ export interface SvelteComponentElement extends BaseSvelteElement {
129
160
| SvelteAwaitCatchBlock
130
161
| SvelteKeyBlock
131
162
}
163
+ /** Node of Svelte special component element. e.g. `<svelte:window>` */
132
164
export interface SvelteSpecialElement extends BaseSvelteElement {
133
165
type : "SvelteElement"
134
166
kind : "special"
135
167
name : SvelteName
136
168
attributes : (
137
169
| SvelteAttribute
170
+ | SvelteShorthandAttribute
138
171
| SvelteSpreadAttribute
139
172
| SvelteDirective
140
173
| SvelteSpecialDirective
@@ -151,15 +184,16 @@ export interface SvelteSpecialElement extends BaseSvelteElement {
151
184
| SvelteAwaitCatchBlock
152
185
| SvelteKeyBlock
153
186
}
154
- export type SvelteElement =
155
- | SvelteHTMLElement
156
- | SvelteComponentElement
157
- | SvelteSpecialElement
158
187
188
+ /** Node of names. It is used for element names other than components and normal attribute names. */
159
189
export interface SvelteName extends BaseNode {
160
190
type : "SvelteName"
161
191
name : string
162
- parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
192
+ parent :
193
+ | SvelteElement
194
+ | SvelteScriptElement
195
+ | SvelteStyleElement
196
+ | SvelteAttribute
163
197
}
164
198
165
199
type Child =
@@ -173,6 +207,7 @@ type Child =
173
207
| SvelteKeyBlock
174
208
| SvelteHTMLComment
175
209
210
+ /** Node of text line HTML text. */
176
211
export interface SvelteText extends BaseNode {
177
212
type : "SvelteText"
178
213
value : string
@@ -202,15 +237,18 @@ interface BaseSvelteMustacheTag extends BaseNode {
202
237
| SvelteKeyBlock
203
238
| SvelteAttribute
204
239
}
240
+ /** Node of mustache tag. e.g. `{...}`, `{@html ...}` */
205
241
export interface SvelteMustacheTag extends BaseSvelteMustacheTag {
206
242
type : "SvelteMustacheTag"
207
243
kind : "text" | "raw"
208
244
expression : ESTree . Expression
209
245
}
246
+ /** Node of debug mustache tag. e.g. `{@debug }` */
210
247
export interface SvelteDebugTag extends BaseSvelteMustacheTag {
211
248
type : "SvelteDebugTag"
212
249
identifiers : ESTree . Identifier [ ]
213
250
}
251
+ /** Node of if block. e.g. `{#if}` */
214
252
export interface SvelteIfBlock extends BaseNode {
215
253
type : "SvelteIfBlock"
216
254
elseif : boolean
@@ -228,11 +266,13 @@ export interface SvelteIfBlock extends BaseNode {
228
266
| SvelteAwaitCatchBlock
229
267
| SvelteKeyBlock
230
268
}
269
+ /** Node of else block. e.g. `{:else}` */
231
270
export interface SvelteElseBlock extends BaseNode {
232
271
type : "SvelteElseBlock"
233
272
children : Child [ ]
234
273
parent : SvelteIfBlock | SvelteEachBlock
235
274
}
275
+ /** Node of each block. e.g. `{#each}` */
236
276
export interface SvelteEachBlock extends BaseNode {
237
277
type : "SvelteEachBlock"
238
278
expression : ESTree . Expression
@@ -252,6 +292,7 @@ export interface SvelteEachBlock extends BaseNode {
252
292
| SvelteAwaitCatchBlock
253
293
| SvelteKeyBlock
254
294
}
295
+ /** Node of await block. e.g. `{#await}` */
255
296
export interface SvelteAwaitBlock extends BaseNode {
256
297
type : "SvelteAwaitBlock"
257
298
expression : ESTree . Expression
@@ -269,23 +310,27 @@ export interface SvelteAwaitBlock extends BaseNode {
269
310
| SvelteAwaitCatchBlock
270
311
| SvelteKeyBlock
271
312
}
313
+ /** Node of await pending block. e.g. `{#await expr} ... {:then}` */
272
314
export interface SvelteAwaitPendingBlock extends BaseNode {
273
315
type : "SvelteAwaitPendingBlock"
274
316
children : Child [ ]
275
317
parent : SvelteAwaitBlock
276
318
}
319
+ /** Node of await then block. e.g. `{:then}` */
277
320
export interface SvelteAwaitThenBlock extends BaseNode {
278
321
type : "SvelteAwaitThenBlock"
279
322
value : ESTree . Pattern
280
323
children : Child [ ]
281
324
parent : SvelteAwaitBlock
282
325
}
326
+ /** Node of await catch block. e.g. `{:catch}` */
283
327
export interface SvelteAwaitCatchBlock extends BaseNode {
284
328
type : "SvelteAwaitCatchBlock"
285
329
error : ESTree . Pattern
286
330
children : Child [ ]
287
331
parent : SvelteAwaitBlock
288
332
}
333
+ /** Node of key block. e.g. `{#key}` */
289
334
export interface SvelteKeyBlock extends BaseNode {
290
335
type : "SvelteKeyBlock"
291
336
expression : ESTree . Expression
@@ -301,6 +346,7 @@ export interface SvelteKeyBlock extends BaseNode {
301
346
| SvelteAwaitCatchBlock
302
347
| SvelteKeyBlock
303
348
}
349
+ /** Node of HTML comment. */
304
350
export interface SvelteHTMLComment extends BaseNode {
305
351
type : "SvelteHTMLComment"
306
352
value : string
@@ -315,32 +361,38 @@ export interface SvelteHTMLComment extends BaseNode {
315
361
| SvelteAwaitCatchBlock
316
362
| SvelteKeyBlock
317
363
}
318
-
319
- export interface SvelteAttributeNonShorthand extends BaseNode {
364
+ /** Node of HTML comment. */
365
+ export interface SvelteAttribute extends BaseNode {
320
366
type : "SvelteAttribute"
321
- key : ESTree . Identifier
322
- shorthand : false
367
+ key : SvelteName
323
368
boolean : boolean
324
369
value : ( SvelteText | ( SvelteMustacheTag & { kind : "text" } ) ) [ ]
325
370
parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
326
371
}
327
- export interface SvelteAttributeShorthand extends BaseNode {
328
- type : "SvelteAttribute"
372
+ /** Node of shorthand attribute. e.g. `<img {src}>` */
373
+ export interface SvelteShorthandAttribute extends BaseNode {
374
+ type : "SvelteShorthandAttribute"
329
375
key : ESTree . Identifier
330
- shorthand : true
331
- boolean : boolean
332
- value : [ ESTree . Identifier ]
376
+ value : ESTree . Identifier
333
377
parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
334
378
}
335
- export type SvelteAttribute =
336
- | SvelteAttributeNonShorthand
337
- | SvelteAttributeShorthand
379
+ /** Node of spread attribute. e.g. `<Info {...pkg}/>` */
338
380
export interface SvelteSpreadAttribute extends BaseNode {
339
381
type : "SvelteSpreadAttribute"
340
382
expression : ESTree . Expression
341
383
parent : SvelteElement | SvelteScriptElement | SvelteStyleElement
342
384
}
343
385
386
+ /** Node of directive. e.g. `<input bind:value />` */
387
+ export type SvelteDirective =
388
+ | SvelteActionDirective
389
+ | SvelteAnimationDirective
390
+ | SvelteBindingDirective
391
+ | SvelteClassDirective
392
+ | SvelteEventHandlerDirective
393
+ | SvelteLetDirective
394
+ | SvelteRefDirective
395
+ | SvelteTransitionDirective
344
396
interface BaseSvelteDirective extends BaseNode {
345
397
type : "SvelteDirective"
346
398
name : ESTree . Identifier
@@ -389,16 +441,7 @@ export interface SvelteSpecialDirective extends BaseNode {
389
441
parent : SvelteSpecialElement
390
442
}
391
443
392
- export type SvelteDirective =
393
- | SvelteActionDirective
394
- | SvelteAnimationDirective
395
- | SvelteBindingDirective
396
- | SvelteClassDirective
397
- | SvelteEventHandlerDirective
398
- | SvelteLetDirective
399
- | SvelteRefDirective
400
- | SvelteTransitionDirective
401
-
444
+ /** Node of `$` statement. */
402
445
export interface SvelteReactiveStatement extends BaseNode {
403
446
type : "SvelteReactiveStatement"
404
447
label : ESTree . Identifier & { name : "$" }
0 commit comments