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