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