@gi-tcg/gts-transpiler 0.6.2 → 0.6.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/dist/index.d.ts +1380 -499
- package/dist/index.js +60 -4
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/parse/index.ts +5 -0
- package/src/parse/loose_plugin.ts +76 -2
- package/src/transform/volar/printer.ts +40 -7
- package/src/types.ts +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,502 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as acorn from "acorn";
|
|
2
|
+
import { Options as Options$1, Parser as Parser$1 } from "acorn";
|
|
3
|
+
import * as AST from "estree";
|
|
4
|
+
import { Program, SourceLocation } from "estree";
|
|
2
5
|
import { SourceMap } from "magic-string";
|
|
3
6
|
|
|
4
|
-
//#region node_modules/@types/estree/index.d.ts
|
|
5
|
-
// This definition file follows a somewhat unusual format. ESTree allows
|
|
6
|
-
// runtime type checks based on the `type` parameter. In order to explain this
|
|
7
|
-
// to typescript we want to use discriminated union types:
|
|
8
|
-
// https://github.com/Microsoft/TypeScript/pull/9163
|
|
9
|
-
//
|
|
10
|
-
// For ESTree this is a bit tricky because the high level interfaces like
|
|
11
|
-
// Node or Function are pulling double duty. We want to pass common fields down
|
|
12
|
-
// to the interfaces that extend them (like Identifier or
|
|
13
|
-
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
|
14
|
-
// common fields on them. So we've split the high level interfaces into two
|
|
15
|
-
// types, a base type which passes down inherited fields, and a type union of
|
|
16
|
-
// all types which extend the base type. Only the type union is exported, and
|
|
17
|
-
// the union is how other types refer to the collection of inheriting types.
|
|
18
|
-
//
|
|
19
|
-
// This makes the definitions file here somewhat more difficult to maintain,
|
|
20
|
-
// but it has the notable advantage of making ESTree much easier to use as
|
|
21
|
-
// an end user.
|
|
22
|
-
interface BaseNodeWithoutComments {
|
|
23
|
-
// Every leaf interface that extends BaseNode must specify a type property.
|
|
24
|
-
// The type property should be a string literal. For example, Identifier
|
|
25
|
-
// has: `type: "Identifier"`
|
|
26
|
-
type: string;
|
|
27
|
-
loc?: SourceLocation | null | undefined;
|
|
28
|
-
range?: [number, number] | undefined;
|
|
29
|
-
}
|
|
30
|
-
interface BaseNode extends BaseNodeWithoutComments {
|
|
31
|
-
leadingComments?: Comment[] | undefined;
|
|
32
|
-
trailingComments?: Comment[] | undefined;
|
|
33
|
-
}
|
|
34
|
-
interface Comment extends BaseNodeWithoutComments {
|
|
35
|
-
type: "Line" | "Block";
|
|
36
|
-
value: string;
|
|
37
|
-
}
|
|
38
|
-
interface SourceLocation {
|
|
39
|
-
source?: string | null | undefined;
|
|
40
|
-
start: Position;
|
|
41
|
-
end: Position;
|
|
42
|
-
}
|
|
43
|
-
interface Position {
|
|
44
|
-
/** >= 1 */
|
|
45
|
-
line: number;
|
|
46
|
-
/** >= 0 */
|
|
47
|
-
column: number;
|
|
48
|
-
}
|
|
49
|
-
interface Program extends BaseNode {
|
|
50
|
-
type: "Program";
|
|
51
|
-
sourceType: "script" | "module";
|
|
52
|
-
body: Array<Directive | Statement | ModuleDeclaration>;
|
|
53
|
-
comments?: Comment[] | undefined;
|
|
54
|
-
}
|
|
55
|
-
interface Directive extends BaseNode {
|
|
56
|
-
type: "ExpressionStatement";
|
|
57
|
-
expression: Literal;
|
|
58
|
-
directive: string;
|
|
59
|
-
}
|
|
60
|
-
interface BaseFunction extends BaseNode {
|
|
61
|
-
params: Pattern[];
|
|
62
|
-
generator?: boolean | undefined;
|
|
63
|
-
async?: boolean | undefined; // The body is either BlockStatement or Expression because arrow functions
|
|
64
|
-
// can have a body that's either. FunctionDeclarations and
|
|
65
|
-
// FunctionExpressions have only BlockStatement bodies.
|
|
66
|
-
body: BlockStatement | Expression;
|
|
67
|
-
}
|
|
68
|
-
type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
|
|
69
|
-
interface BaseStatement extends BaseNode {}
|
|
70
|
-
interface EmptyStatement extends BaseStatement {
|
|
71
|
-
type: "EmptyStatement";
|
|
72
|
-
}
|
|
73
|
-
interface BlockStatement extends BaseStatement {
|
|
74
|
-
type: "BlockStatement";
|
|
75
|
-
body: Statement[];
|
|
76
|
-
innerComments?: Comment[] | undefined;
|
|
77
|
-
}
|
|
78
|
-
interface StaticBlock extends Omit<BlockStatement, "type"> {
|
|
79
|
-
type: "StaticBlock";
|
|
80
|
-
}
|
|
81
|
-
interface ExpressionStatement extends BaseStatement {
|
|
82
|
-
type: "ExpressionStatement";
|
|
83
|
-
expression: Expression;
|
|
84
|
-
}
|
|
85
|
-
interface IfStatement extends BaseStatement {
|
|
86
|
-
type: "IfStatement";
|
|
87
|
-
test: Expression;
|
|
88
|
-
consequent: Statement;
|
|
89
|
-
alternate?: Statement | null | undefined;
|
|
90
|
-
}
|
|
91
|
-
interface LabeledStatement extends BaseStatement {
|
|
92
|
-
type: "LabeledStatement";
|
|
93
|
-
label: Identifier;
|
|
94
|
-
body: Statement;
|
|
95
|
-
}
|
|
96
|
-
interface BreakStatement extends BaseStatement {
|
|
97
|
-
type: "BreakStatement";
|
|
98
|
-
label?: Identifier | null | undefined;
|
|
99
|
-
}
|
|
100
|
-
interface ContinueStatement extends BaseStatement {
|
|
101
|
-
type: "ContinueStatement";
|
|
102
|
-
label?: Identifier | null | undefined;
|
|
103
|
-
}
|
|
104
|
-
interface WithStatement extends BaseStatement {
|
|
105
|
-
type: "WithStatement";
|
|
106
|
-
object: Expression;
|
|
107
|
-
body: Statement;
|
|
108
|
-
}
|
|
109
|
-
interface SwitchStatement extends BaseStatement {
|
|
110
|
-
type: "SwitchStatement";
|
|
111
|
-
discriminant: Expression;
|
|
112
|
-
cases: SwitchCase[];
|
|
113
|
-
}
|
|
114
|
-
interface ReturnStatement extends BaseStatement {
|
|
115
|
-
type: "ReturnStatement";
|
|
116
|
-
argument?: Expression | null | undefined;
|
|
117
|
-
}
|
|
118
|
-
interface ThrowStatement extends BaseStatement {
|
|
119
|
-
type: "ThrowStatement";
|
|
120
|
-
argument: Expression;
|
|
121
|
-
}
|
|
122
|
-
interface TryStatement extends BaseStatement {
|
|
123
|
-
type: "TryStatement";
|
|
124
|
-
block: BlockStatement;
|
|
125
|
-
handler?: CatchClause | null | undefined;
|
|
126
|
-
finalizer?: BlockStatement | null | undefined;
|
|
127
|
-
}
|
|
128
|
-
interface WhileStatement extends BaseStatement {
|
|
129
|
-
type: "WhileStatement";
|
|
130
|
-
test: Expression;
|
|
131
|
-
body: Statement;
|
|
132
|
-
}
|
|
133
|
-
interface DoWhileStatement extends BaseStatement {
|
|
134
|
-
type: "DoWhileStatement";
|
|
135
|
-
body: Statement;
|
|
136
|
-
test: Expression;
|
|
137
|
-
}
|
|
138
|
-
interface ForStatement extends BaseStatement {
|
|
139
|
-
type: "ForStatement";
|
|
140
|
-
init?: VariableDeclaration | Expression | null | undefined;
|
|
141
|
-
test?: Expression | null | undefined;
|
|
142
|
-
update?: Expression | null | undefined;
|
|
143
|
-
body: Statement;
|
|
144
|
-
}
|
|
145
|
-
interface BaseForXStatement extends BaseStatement {
|
|
146
|
-
left: VariableDeclaration | Pattern;
|
|
147
|
-
right: Expression;
|
|
148
|
-
body: Statement;
|
|
149
|
-
}
|
|
150
|
-
interface ForInStatement extends BaseForXStatement {
|
|
151
|
-
type: "ForInStatement";
|
|
152
|
-
}
|
|
153
|
-
interface DebuggerStatement extends BaseStatement {
|
|
154
|
-
type: "DebuggerStatement";
|
|
155
|
-
}
|
|
156
|
-
type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
|
157
|
-
interface BaseDeclaration extends BaseStatement {}
|
|
158
|
-
interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
|
159
|
-
type: "FunctionDeclaration";
|
|
160
|
-
/** It is null when a function declaration is a part of the `export default function` statement */
|
|
161
|
-
id: Identifier | null;
|
|
162
|
-
body: BlockStatement;
|
|
163
|
-
}
|
|
164
|
-
interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
|
165
|
-
id: Identifier;
|
|
166
|
-
}
|
|
167
|
-
interface VariableDeclaration extends BaseDeclaration {
|
|
168
|
-
type: "VariableDeclaration";
|
|
169
|
-
declarations: VariableDeclarator[];
|
|
170
|
-
kind: "var" | "let" | "const" | "using" | "await using";
|
|
171
|
-
}
|
|
172
|
-
interface VariableDeclarator extends BaseNode {
|
|
173
|
-
type: "VariableDeclarator";
|
|
174
|
-
id: Pattern;
|
|
175
|
-
init?: Expression | null | undefined;
|
|
176
|
-
}
|
|
177
|
-
interface ExpressionMap {
|
|
178
|
-
ArrayExpression: ArrayExpression;
|
|
179
|
-
ArrowFunctionExpression: ArrowFunctionExpression;
|
|
180
|
-
AssignmentExpression: AssignmentExpression;
|
|
181
|
-
AwaitExpression: AwaitExpression;
|
|
182
|
-
BinaryExpression: BinaryExpression;
|
|
183
|
-
CallExpression: CallExpression;
|
|
184
|
-
ChainExpression: ChainExpression;
|
|
185
|
-
ClassExpression: ClassExpression;
|
|
186
|
-
ConditionalExpression: ConditionalExpression;
|
|
187
|
-
FunctionExpression: FunctionExpression;
|
|
188
|
-
Identifier: Identifier;
|
|
189
|
-
ImportExpression: ImportExpression;
|
|
190
|
-
Literal: Literal;
|
|
191
|
-
LogicalExpression: LogicalExpression;
|
|
192
|
-
MemberExpression: MemberExpression;
|
|
193
|
-
MetaProperty: MetaProperty;
|
|
194
|
-
NewExpression: NewExpression;
|
|
195
|
-
ObjectExpression: ObjectExpression;
|
|
196
|
-
SequenceExpression: SequenceExpression;
|
|
197
|
-
TaggedTemplateExpression: TaggedTemplateExpression;
|
|
198
|
-
TemplateLiteral: TemplateLiteral;
|
|
199
|
-
ThisExpression: ThisExpression;
|
|
200
|
-
UnaryExpression: UnaryExpression;
|
|
201
|
-
UpdateExpression: UpdateExpression;
|
|
202
|
-
YieldExpression: YieldExpression;
|
|
203
|
-
}
|
|
204
|
-
type Expression = ExpressionMap[keyof ExpressionMap];
|
|
205
|
-
interface BaseExpression extends BaseNode {}
|
|
206
|
-
type ChainElement = SimpleCallExpression | MemberExpression;
|
|
207
|
-
interface ChainExpression extends BaseExpression {
|
|
208
|
-
type: "ChainExpression";
|
|
209
|
-
expression: ChainElement;
|
|
210
|
-
}
|
|
211
|
-
interface ThisExpression extends BaseExpression {
|
|
212
|
-
type: "ThisExpression";
|
|
213
|
-
}
|
|
214
|
-
interface ArrayExpression extends BaseExpression {
|
|
215
|
-
type: "ArrayExpression";
|
|
216
|
-
elements: Array<Expression | SpreadElement | null>;
|
|
217
|
-
}
|
|
218
|
-
interface ObjectExpression extends BaseExpression {
|
|
219
|
-
type: "ObjectExpression";
|
|
220
|
-
properties: Array<Property | SpreadElement>;
|
|
221
|
-
}
|
|
222
|
-
interface PrivateIdentifier extends BaseNode {
|
|
223
|
-
type: "PrivateIdentifier";
|
|
224
|
-
name: string;
|
|
225
|
-
}
|
|
226
|
-
interface Property extends BaseNode {
|
|
227
|
-
type: "Property";
|
|
228
|
-
key: Expression;
|
|
229
|
-
value: Expression | Pattern; // Could be an AssignmentProperty
|
|
230
|
-
kind: "init" | "get" | "set";
|
|
231
|
-
method: boolean;
|
|
232
|
-
shorthand: boolean;
|
|
233
|
-
computed: boolean;
|
|
234
|
-
}
|
|
235
|
-
interface PropertyDefinition extends BaseNode {
|
|
236
|
-
type: "PropertyDefinition";
|
|
237
|
-
key: Expression | PrivateIdentifier;
|
|
238
|
-
value?: Expression | null | undefined;
|
|
239
|
-
computed: boolean;
|
|
240
|
-
static: boolean;
|
|
241
|
-
}
|
|
242
|
-
interface FunctionExpression extends BaseFunction, BaseExpression {
|
|
243
|
-
id?: Identifier | null | undefined;
|
|
244
|
-
type: "FunctionExpression";
|
|
245
|
-
body: BlockStatement;
|
|
246
|
-
}
|
|
247
|
-
interface SequenceExpression extends BaseExpression {
|
|
248
|
-
type: "SequenceExpression";
|
|
249
|
-
expressions: Expression[];
|
|
250
|
-
}
|
|
251
|
-
interface UnaryExpression extends BaseExpression {
|
|
252
|
-
type: "UnaryExpression";
|
|
253
|
-
operator: UnaryOperator;
|
|
254
|
-
prefix: true;
|
|
255
|
-
argument: Expression;
|
|
256
|
-
}
|
|
257
|
-
interface BinaryExpression extends BaseExpression {
|
|
258
|
-
type: "BinaryExpression";
|
|
259
|
-
operator: BinaryOperator;
|
|
260
|
-
left: Expression | PrivateIdentifier;
|
|
261
|
-
right: Expression;
|
|
262
|
-
}
|
|
263
|
-
interface AssignmentExpression extends BaseExpression {
|
|
264
|
-
type: "AssignmentExpression";
|
|
265
|
-
operator: AssignmentOperator;
|
|
266
|
-
left: Pattern | MemberExpression;
|
|
267
|
-
right: Expression;
|
|
268
|
-
}
|
|
269
|
-
interface UpdateExpression extends BaseExpression {
|
|
270
|
-
type: "UpdateExpression";
|
|
271
|
-
operator: UpdateOperator;
|
|
272
|
-
argument: Expression;
|
|
273
|
-
prefix: boolean;
|
|
274
|
-
}
|
|
275
|
-
interface LogicalExpression extends BaseExpression {
|
|
276
|
-
type: "LogicalExpression";
|
|
277
|
-
operator: LogicalOperator;
|
|
278
|
-
left: Expression;
|
|
279
|
-
right: Expression;
|
|
280
|
-
}
|
|
281
|
-
interface ConditionalExpression extends BaseExpression {
|
|
282
|
-
type: "ConditionalExpression";
|
|
283
|
-
test: Expression;
|
|
284
|
-
alternate: Expression;
|
|
285
|
-
consequent: Expression;
|
|
286
|
-
}
|
|
287
|
-
interface BaseCallExpression extends BaseExpression {
|
|
288
|
-
callee: Expression | Super;
|
|
289
|
-
arguments: Array<Expression | SpreadElement>;
|
|
290
|
-
}
|
|
291
|
-
type CallExpression = SimpleCallExpression | NewExpression;
|
|
292
|
-
interface SimpleCallExpression extends BaseCallExpression {
|
|
293
|
-
type: "CallExpression";
|
|
294
|
-
optional: boolean;
|
|
295
|
-
}
|
|
296
|
-
interface NewExpression extends BaseCallExpression {
|
|
297
|
-
type: "NewExpression";
|
|
298
|
-
}
|
|
299
|
-
interface MemberExpression extends BaseExpression, BasePattern {
|
|
300
|
-
type: "MemberExpression";
|
|
301
|
-
object: Expression | Super;
|
|
302
|
-
property: Expression | PrivateIdentifier;
|
|
303
|
-
computed: boolean;
|
|
304
|
-
optional: boolean;
|
|
305
|
-
}
|
|
306
|
-
type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
|
307
|
-
interface BasePattern extends BaseNode {}
|
|
308
|
-
interface SwitchCase extends BaseNode {
|
|
309
|
-
type: "SwitchCase";
|
|
310
|
-
test?: Expression | null | undefined;
|
|
311
|
-
consequent: Statement[];
|
|
312
|
-
}
|
|
313
|
-
interface CatchClause extends BaseNode {
|
|
314
|
-
type: "CatchClause";
|
|
315
|
-
param: Pattern | null;
|
|
316
|
-
body: BlockStatement;
|
|
317
|
-
}
|
|
318
|
-
interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
|
319
|
-
type: "Identifier";
|
|
320
|
-
name: string;
|
|
321
|
-
}
|
|
322
|
-
type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
|
323
|
-
interface SimpleLiteral extends BaseNode, BaseExpression {
|
|
324
|
-
type: "Literal";
|
|
325
|
-
value: string | boolean | number | null;
|
|
326
|
-
raw?: string | undefined;
|
|
327
|
-
}
|
|
328
|
-
interface RegExpLiteral extends BaseNode, BaseExpression {
|
|
329
|
-
type: "Literal";
|
|
330
|
-
value?: RegExp | null | undefined;
|
|
331
|
-
regex: {
|
|
332
|
-
pattern: string;
|
|
333
|
-
flags: string;
|
|
334
|
-
};
|
|
335
|
-
raw?: string | undefined;
|
|
336
|
-
}
|
|
337
|
-
interface BigIntLiteral extends BaseNode, BaseExpression {
|
|
338
|
-
type: "Literal";
|
|
339
|
-
value?: bigint | null | undefined;
|
|
340
|
-
bigint: string;
|
|
341
|
-
raw?: string | undefined;
|
|
342
|
-
}
|
|
343
|
-
type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
|
344
|
-
type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
|
|
345
|
-
type LogicalOperator = "||" | "&&" | "??";
|
|
346
|
-
type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
|
|
347
|
-
type UpdateOperator = "++" | "--";
|
|
348
|
-
interface ForOfStatement extends BaseForXStatement {
|
|
349
|
-
type: "ForOfStatement";
|
|
350
|
-
await: boolean;
|
|
351
|
-
}
|
|
352
|
-
interface Super extends BaseNode {
|
|
353
|
-
type: "Super";
|
|
354
|
-
}
|
|
355
|
-
interface SpreadElement extends BaseNode {
|
|
356
|
-
type: "SpreadElement";
|
|
357
|
-
argument: Expression;
|
|
358
|
-
}
|
|
359
|
-
interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
|
360
|
-
type: "ArrowFunctionExpression";
|
|
361
|
-
expression: boolean;
|
|
362
|
-
body: BlockStatement | Expression;
|
|
363
|
-
}
|
|
364
|
-
interface YieldExpression extends BaseExpression {
|
|
365
|
-
type: "YieldExpression";
|
|
366
|
-
argument?: Expression | null | undefined;
|
|
367
|
-
delegate: boolean;
|
|
368
|
-
}
|
|
369
|
-
interface TemplateLiteral extends BaseExpression {
|
|
370
|
-
type: "TemplateLiteral";
|
|
371
|
-
quasis: TemplateElement[];
|
|
372
|
-
expressions: Expression[];
|
|
373
|
-
}
|
|
374
|
-
interface TaggedTemplateExpression extends BaseExpression {
|
|
375
|
-
type: "TaggedTemplateExpression";
|
|
376
|
-
tag: Expression;
|
|
377
|
-
quasi: TemplateLiteral;
|
|
378
|
-
}
|
|
379
|
-
interface TemplateElement extends BaseNode {
|
|
380
|
-
type: "TemplateElement";
|
|
381
|
-
tail: boolean;
|
|
382
|
-
value: {
|
|
383
|
-
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */cooked?: string | null | undefined;
|
|
384
|
-
raw: string;
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
interface AssignmentProperty extends Property {
|
|
388
|
-
value: Pattern;
|
|
389
|
-
kind: "init";
|
|
390
|
-
method: boolean; // false
|
|
391
|
-
}
|
|
392
|
-
interface ObjectPattern extends BasePattern {
|
|
393
|
-
type: "ObjectPattern";
|
|
394
|
-
properties: Array<AssignmentProperty | RestElement>;
|
|
395
|
-
}
|
|
396
|
-
interface ArrayPattern extends BasePattern {
|
|
397
|
-
type: "ArrayPattern";
|
|
398
|
-
elements: Array<Pattern | null>;
|
|
399
|
-
}
|
|
400
|
-
interface RestElement extends BasePattern {
|
|
401
|
-
type: "RestElement";
|
|
402
|
-
argument: Pattern;
|
|
403
|
-
}
|
|
404
|
-
interface AssignmentPattern extends BasePattern {
|
|
405
|
-
type: "AssignmentPattern";
|
|
406
|
-
left: Pattern;
|
|
407
|
-
right: Expression;
|
|
408
|
-
}
|
|
409
|
-
interface BaseClass extends BaseNode {
|
|
410
|
-
superClass?: Expression | null | undefined;
|
|
411
|
-
body: ClassBody;
|
|
412
|
-
}
|
|
413
|
-
interface ClassBody extends BaseNode {
|
|
414
|
-
type: "ClassBody";
|
|
415
|
-
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
|
416
|
-
}
|
|
417
|
-
interface MethodDefinition extends BaseNode {
|
|
418
|
-
type: "MethodDefinition";
|
|
419
|
-
key: Expression | PrivateIdentifier;
|
|
420
|
-
value: FunctionExpression;
|
|
421
|
-
kind: "constructor" | "method" | "get" | "set";
|
|
422
|
-
computed: boolean;
|
|
423
|
-
static: boolean;
|
|
424
|
-
}
|
|
425
|
-
interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
|
426
|
-
type: "ClassDeclaration";
|
|
427
|
-
/** It is null when a class declaration is a part of the `export default class` statement */
|
|
428
|
-
id: Identifier | null;
|
|
429
|
-
}
|
|
430
|
-
interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
|
431
|
-
id: Identifier;
|
|
432
|
-
}
|
|
433
|
-
interface ClassExpression extends BaseClass, BaseExpression {
|
|
434
|
-
type: "ClassExpression";
|
|
435
|
-
id?: Identifier | null | undefined;
|
|
436
|
-
}
|
|
437
|
-
interface MetaProperty extends BaseExpression {
|
|
438
|
-
type: "MetaProperty";
|
|
439
|
-
meta: Identifier;
|
|
440
|
-
property: Identifier;
|
|
441
|
-
}
|
|
442
|
-
type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration;
|
|
443
|
-
interface BaseModuleDeclaration extends BaseNode {}
|
|
444
|
-
interface BaseModuleSpecifier extends BaseNode {
|
|
445
|
-
local: Identifier;
|
|
446
|
-
}
|
|
447
|
-
interface ImportDeclaration extends BaseModuleDeclaration {
|
|
448
|
-
type: "ImportDeclaration";
|
|
449
|
-
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
|
450
|
-
attributes: ImportAttribute[];
|
|
451
|
-
source: Literal;
|
|
452
|
-
}
|
|
453
|
-
interface ImportSpecifier extends BaseModuleSpecifier {
|
|
454
|
-
type: "ImportSpecifier";
|
|
455
|
-
imported: Identifier | Literal;
|
|
456
|
-
}
|
|
457
|
-
interface ImportAttribute extends BaseNode {
|
|
458
|
-
type: "ImportAttribute";
|
|
459
|
-
key: Identifier | Literal;
|
|
460
|
-
value: Literal;
|
|
461
|
-
}
|
|
462
|
-
interface ImportExpression extends BaseExpression {
|
|
463
|
-
type: "ImportExpression";
|
|
464
|
-
source: Expression;
|
|
465
|
-
options?: Expression | null | undefined;
|
|
466
|
-
}
|
|
467
|
-
interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
|
468
|
-
type: "ImportDefaultSpecifier";
|
|
469
|
-
}
|
|
470
|
-
interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
|
471
|
-
type: "ImportNamespaceSpecifier";
|
|
472
|
-
}
|
|
473
|
-
interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
|
474
|
-
type: "ExportNamedDeclaration";
|
|
475
|
-
declaration?: Declaration | null | undefined;
|
|
476
|
-
specifiers: ExportSpecifier[];
|
|
477
|
-
attributes: ImportAttribute[];
|
|
478
|
-
source?: Literal | null | undefined;
|
|
479
|
-
}
|
|
480
|
-
interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
|
481
|
-
type: "ExportSpecifier";
|
|
482
|
-
local: Identifier | Literal;
|
|
483
|
-
exported: Identifier | Literal;
|
|
484
|
-
}
|
|
485
|
-
interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
|
486
|
-
type: "ExportDefaultDeclaration";
|
|
487
|
-
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
|
488
|
-
}
|
|
489
|
-
interface ExportAllDeclaration extends BaseModuleDeclaration {
|
|
490
|
-
type: "ExportAllDeclaration";
|
|
491
|
-
exported: Identifier | Literal | null;
|
|
492
|
-
attributes: ImportAttribute[];
|
|
493
|
-
source: Literal;
|
|
494
|
-
}
|
|
495
|
-
interface AwaitExpression extends BaseExpression {
|
|
496
|
-
type: "AwaitExpression";
|
|
497
|
-
argument: Expression;
|
|
498
|
-
}
|
|
499
|
-
//#endregion
|
|
500
7
|
//#region src/parse/gts_plugin.d.ts
|
|
501
8
|
interface GtsPluginOption {
|
|
502
9
|
allowEmptyShortcutMember?: boolean;
|
|
@@ -505,7 +12,7 @@ interface GtsPluginOption {
|
|
|
505
12
|
//#endregion
|
|
506
13
|
//#region src/parse/index.d.ts
|
|
507
14
|
interface ParseOptions extends GtsPluginOption {
|
|
508
|
-
onComment: Options["onComment"];
|
|
15
|
+
onComment: Options$1["onComment"];
|
|
509
16
|
}
|
|
510
17
|
declare function parse(input: string, options?: ParseOptions): Program;
|
|
511
18
|
interface ParseLooseOptions extends GtsPluginOption {
|
|
@@ -609,6 +116,1380 @@ declare class GtsTranspilerError extends Error {
|
|
|
609
116
|
constructor(message: string, position: SourceLocation | null);
|
|
610
117
|
}
|
|
611
118
|
//#endregion
|
|
119
|
+
//#region src/types.d.ts
|
|
120
|
+
type ForInit = boolean | "await";
|
|
121
|
+
declare module "estree" {
|
|
122
|
+
interface Identifier {
|
|
123
|
+
isDummy?: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface NodeMap {
|
|
126
|
+
GTSDefineStatement: GTSDefineStatement;
|
|
127
|
+
GTSNamedAttributeDefinition: GTSNamedAttributeDefinition;
|
|
128
|
+
GTSAttributeBody: GTSAttributeBody;
|
|
129
|
+
GTSPositionalAttributeList: GTSPositionalAttributeList;
|
|
130
|
+
GTSNamedAttributeBlock: GTSNamedAttributeBlock;
|
|
131
|
+
GTSDirectFunction: GTSDirectFunction;
|
|
132
|
+
}
|
|
133
|
+
interface ExpressionMap {
|
|
134
|
+
GTSShortcutArgumentExpression: GTSShortcutArgumentExpression;
|
|
135
|
+
GTSShortcutFunctionExpression: GTSShortcutFunctionExpression;
|
|
136
|
+
}
|
|
137
|
+
interface SimpleCallExpression {
|
|
138
|
+
lParenRange?: [number, number];
|
|
139
|
+
}
|
|
140
|
+
interface NewExpression {
|
|
141
|
+
lParenRange?: [number, number];
|
|
142
|
+
}
|
|
143
|
+
interface GTSDefineStatement extends BaseStatement {
|
|
144
|
+
type: "GTSDefineStatement";
|
|
145
|
+
body: GTSNamedAttributeDefinition;
|
|
146
|
+
}
|
|
147
|
+
interface GTSNamedAttributeDefinition extends BaseNode {
|
|
148
|
+
type: "GTSNamedAttributeDefinition";
|
|
149
|
+
name: Identifier | Literal;
|
|
150
|
+
body: GTSAttributeBody;
|
|
151
|
+
bindingAccessModifier?: "public" | "protected" | "private";
|
|
152
|
+
bindingName?: Identifier;
|
|
153
|
+
}
|
|
154
|
+
interface GTSAttributeBody extends BaseNode {
|
|
155
|
+
type: "GTSAttributeBody";
|
|
156
|
+
positionalAttributes: GTSPositionalAttributeList;
|
|
157
|
+
namedAttributes?: GTSNamedAttributeBlock;
|
|
158
|
+
}
|
|
159
|
+
interface GTSPositionalAttributeList extends BaseNode {
|
|
160
|
+
type: "GTSPositionalAttributeList";
|
|
161
|
+
attributes: Expression[];
|
|
162
|
+
}
|
|
163
|
+
interface GTSNamedAttributeBlock extends BaseNode {
|
|
164
|
+
type: "GTSNamedAttributeBlock";
|
|
165
|
+
attributes: GTSNamedAttributeDefinition[];
|
|
166
|
+
directAction?: GTSDirectFunction;
|
|
167
|
+
}
|
|
168
|
+
interface GTSDirectFunction extends BaseNode {
|
|
169
|
+
type: "GTSDirectFunction";
|
|
170
|
+
body: Statement[];
|
|
171
|
+
}
|
|
172
|
+
interface GTSShortcutArgumentExpression extends BaseExpression {
|
|
173
|
+
type: "GTSShortcutArgumentExpression";
|
|
174
|
+
property: Identifier;
|
|
175
|
+
}
|
|
176
|
+
interface GTSShortcutFunctionExpression extends BaseExpression {
|
|
177
|
+
type: "GTSShortcutFunctionExpression";
|
|
178
|
+
body: BlockStatement | Expression;
|
|
179
|
+
expression: boolean;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
declare module "acorn" {
|
|
183
|
+
type ReadToken = Parse.Parser["readToken"];
|
|
184
|
+
const tokContexts: Parse.TokContexts;
|
|
185
|
+
class Position implements AST.Position {
|
|
186
|
+
line: number;
|
|
187
|
+
column: number;
|
|
188
|
+
constructor(line: number, column: number);
|
|
189
|
+
}
|
|
190
|
+
function isNewLine(code: number): boolean;
|
|
191
|
+
interface Parser {
|
|
192
|
+
readToken(...args: Parameters<ReadToken>): ReturnType<ReadToken>;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
declare namespace Parse {
|
|
196
|
+
/**
|
|
197
|
+
* Destructuring errors object used during expression parsing
|
|
198
|
+
* See: https://github.com/acornjs/acorn/blob/main/acorn/src/parseutil.js
|
|
199
|
+
*/
|
|
200
|
+
export interface DestructuringErrors {
|
|
201
|
+
shorthandAssign: number;
|
|
202
|
+
trailingComma: number;
|
|
203
|
+
parenthesizedAssign: number;
|
|
204
|
+
parenthesizedBind: number;
|
|
205
|
+
doubleProto: number;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Binding type constants used in checkLVal* and declareName
|
|
209
|
+
* to determine the type of a binding
|
|
210
|
+
*/
|
|
211
|
+
export interface BindingType {
|
|
212
|
+
/** Not a binding */
|
|
213
|
+
BIND_NONE: 0;
|
|
214
|
+
/** Var-style binding */
|
|
215
|
+
BIND_VAR: 1;
|
|
216
|
+
/** Let- or const-style binding */
|
|
217
|
+
BIND_LEXICAL: 2;
|
|
218
|
+
/** Function declaration */
|
|
219
|
+
BIND_FUNCTION: 3;
|
|
220
|
+
/** Simple (identifier pattern) catch binding */
|
|
221
|
+
BIND_SIMPLE_CATCH: 4;
|
|
222
|
+
/** Special case for function names as bound inside the function */
|
|
223
|
+
BIND_OUTSIDE: 5;
|
|
224
|
+
}
|
|
225
|
+
export interface Options extends acorn.Options {}
|
|
226
|
+
export interface CommentMetaData {
|
|
227
|
+
containerId: number;
|
|
228
|
+
childIndex: number;
|
|
229
|
+
beforeMeaningfulChild: boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Token context - controls how tokens are interpreted in different syntactic contexts
|
|
233
|
+
*/
|
|
234
|
+
export interface TokContext {
|
|
235
|
+
token: string;
|
|
236
|
+
isExpr: boolean;
|
|
237
|
+
preserveSpace?: boolean;
|
|
238
|
+
override?: ((parser: Parser) => acorn.Token) | null;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Token type definition
|
|
242
|
+
*/
|
|
243
|
+
export interface TokenType {
|
|
244
|
+
label: string;
|
|
245
|
+
keyword: string | undefined;
|
|
246
|
+
beforeExpr?: boolean;
|
|
247
|
+
startsExpr?: boolean;
|
|
248
|
+
isLoop?: boolean;
|
|
249
|
+
isAssign?: boolean;
|
|
250
|
+
prefix?: boolean;
|
|
251
|
+
postfix?: boolean;
|
|
252
|
+
binop?: number | null;
|
|
253
|
+
updateContext?: ((prevType: TokenType) => void) | null;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Acorn's built-in token contexts
|
|
257
|
+
*/
|
|
258
|
+
export interface TokContexts {
|
|
259
|
+
/** Block statement context - `{` in statement position */
|
|
260
|
+
b_stat: TokContext & {
|
|
261
|
+
token: "{";
|
|
262
|
+
};
|
|
263
|
+
/** Block expression context - `{` in expression position (object literals) */
|
|
264
|
+
b_expr: TokContext & {
|
|
265
|
+
token: "{";
|
|
266
|
+
};
|
|
267
|
+
/** Template literal context - `${` inside template */
|
|
268
|
+
b_tmpl: TokContext & {
|
|
269
|
+
token: "${";
|
|
270
|
+
};
|
|
271
|
+
/** Parenthesized statement context - `(` in statement position */
|
|
272
|
+
p_stat: TokContext & {
|
|
273
|
+
token: "(";
|
|
274
|
+
};
|
|
275
|
+
/** Parenthesized expression context - `(` in expression position */
|
|
276
|
+
p_expr: TokContext & {
|
|
277
|
+
token: "(";
|
|
278
|
+
};
|
|
279
|
+
/** Quasi/template context - `` ` `` backtick */
|
|
280
|
+
q_tmpl: TokContext & {
|
|
281
|
+
token: "`";
|
|
282
|
+
};
|
|
283
|
+
/** Function statement context - `function` keyword in statement */
|
|
284
|
+
f_stat: TokContext & {
|
|
285
|
+
token: "function";
|
|
286
|
+
};
|
|
287
|
+
/** Function expression context - `function` keyword in expression */
|
|
288
|
+
f_expr: TokContext & {
|
|
289
|
+
token: "function";
|
|
290
|
+
};
|
|
291
|
+
/** Generator function expression context - `function*` in expression */
|
|
292
|
+
f_expr_gen: TokContext & {
|
|
293
|
+
token: "function";
|
|
294
|
+
};
|
|
295
|
+
/** Generator function context - `function*` in statement */
|
|
296
|
+
f_gen: TokContext & {
|
|
297
|
+
token: "function";
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Acorn's built-in token types
|
|
302
|
+
*/
|
|
303
|
+
export interface TokTypes {
|
|
304
|
+
num: TokenType & {
|
|
305
|
+
label: "num";
|
|
306
|
+
};
|
|
307
|
+
regexp: TokenType & {
|
|
308
|
+
label: "regexp";
|
|
309
|
+
};
|
|
310
|
+
string: TokenType & {
|
|
311
|
+
label: "string";
|
|
312
|
+
};
|
|
313
|
+
name: TokenType & {
|
|
314
|
+
label: "name";
|
|
315
|
+
};
|
|
316
|
+
privateId: TokenType & {
|
|
317
|
+
label: "privateId";
|
|
318
|
+
};
|
|
319
|
+
eof: TokenType & {
|
|
320
|
+
label: "eof";
|
|
321
|
+
};
|
|
322
|
+
bracketL: TokenType & {
|
|
323
|
+
label: "[";
|
|
324
|
+
};
|
|
325
|
+
bracketR: TokenType & {
|
|
326
|
+
label: "]";
|
|
327
|
+
};
|
|
328
|
+
braceL: TokenType & {
|
|
329
|
+
label: "{";
|
|
330
|
+
};
|
|
331
|
+
braceR: TokenType & {
|
|
332
|
+
label: "}";
|
|
333
|
+
};
|
|
334
|
+
parenL: TokenType & {
|
|
335
|
+
label: "(";
|
|
336
|
+
};
|
|
337
|
+
parenR: TokenType & {
|
|
338
|
+
label: ")";
|
|
339
|
+
};
|
|
340
|
+
comma: TokenType & {
|
|
341
|
+
label: ",";
|
|
342
|
+
};
|
|
343
|
+
semi: TokenType & {
|
|
344
|
+
label: ";";
|
|
345
|
+
};
|
|
346
|
+
colon: TokenType & {
|
|
347
|
+
label: ":";
|
|
348
|
+
};
|
|
349
|
+
dot: TokenType & {
|
|
350
|
+
label: ".";
|
|
351
|
+
};
|
|
352
|
+
question: TokenType & {
|
|
353
|
+
label: "?";
|
|
354
|
+
};
|
|
355
|
+
questionDot: TokenType & {
|
|
356
|
+
label: "?.";
|
|
357
|
+
};
|
|
358
|
+
arrow: TokenType & {
|
|
359
|
+
label: "=>";
|
|
360
|
+
};
|
|
361
|
+
template: TokenType & {
|
|
362
|
+
label: "template";
|
|
363
|
+
};
|
|
364
|
+
invalidTemplate: TokenType & {
|
|
365
|
+
label: "invalidTemplate";
|
|
366
|
+
};
|
|
367
|
+
ellipsis: TokenType & {
|
|
368
|
+
label: "...";
|
|
369
|
+
};
|
|
370
|
+
backQuote: TokenType & {
|
|
371
|
+
label: "`";
|
|
372
|
+
};
|
|
373
|
+
dollarBraceL: TokenType & {
|
|
374
|
+
label: "${";
|
|
375
|
+
};
|
|
376
|
+
eq: TokenType & {
|
|
377
|
+
label: "=";
|
|
378
|
+
isAssign: true;
|
|
379
|
+
};
|
|
380
|
+
assign: TokenType & {
|
|
381
|
+
label: "_=";
|
|
382
|
+
isAssign: true;
|
|
383
|
+
};
|
|
384
|
+
incDec: TokenType & {
|
|
385
|
+
label: "++/--";
|
|
386
|
+
prefix: true;
|
|
387
|
+
postfix: true;
|
|
388
|
+
};
|
|
389
|
+
prefix: TokenType & {
|
|
390
|
+
label: "!/~";
|
|
391
|
+
prefix: true;
|
|
392
|
+
};
|
|
393
|
+
logicalOR: TokenType & {
|
|
394
|
+
label: "||";
|
|
395
|
+
binop: 1;
|
|
396
|
+
};
|
|
397
|
+
logicalAND: TokenType & {
|
|
398
|
+
label: "&&";
|
|
399
|
+
binop: 2;
|
|
400
|
+
};
|
|
401
|
+
bitwiseOR: TokenType & {
|
|
402
|
+
label: "|";
|
|
403
|
+
binop: 3;
|
|
404
|
+
};
|
|
405
|
+
bitwiseXOR: TokenType & {
|
|
406
|
+
label: "^";
|
|
407
|
+
binop: 4;
|
|
408
|
+
};
|
|
409
|
+
bitwiseAND: TokenType & {
|
|
410
|
+
label: "&";
|
|
411
|
+
binop: 5;
|
|
412
|
+
};
|
|
413
|
+
equality: TokenType & {
|
|
414
|
+
label: "==/!=/===/!==";
|
|
415
|
+
binop: 6;
|
|
416
|
+
};
|
|
417
|
+
relational: TokenType & {
|
|
418
|
+
label: "</>/<=/>=";
|
|
419
|
+
binop: 7;
|
|
420
|
+
};
|
|
421
|
+
bitShift: TokenType & {
|
|
422
|
+
label: "<</>>/>>>";
|
|
423
|
+
binop: 8;
|
|
424
|
+
};
|
|
425
|
+
plusMin: TokenType & {
|
|
426
|
+
label: "+/-";
|
|
427
|
+
binop: 9;
|
|
428
|
+
prefix: true;
|
|
429
|
+
};
|
|
430
|
+
modulo: TokenType & {
|
|
431
|
+
label: "%";
|
|
432
|
+
binop: 10;
|
|
433
|
+
};
|
|
434
|
+
star: TokenType & {
|
|
435
|
+
label: "*";
|
|
436
|
+
binop: 10;
|
|
437
|
+
};
|
|
438
|
+
slash: TokenType & {
|
|
439
|
+
label: "/";
|
|
440
|
+
binop: 10;
|
|
441
|
+
};
|
|
442
|
+
starstar: TokenType & {
|
|
443
|
+
label: "**";
|
|
444
|
+
};
|
|
445
|
+
coalesce: TokenType & {
|
|
446
|
+
label: "??";
|
|
447
|
+
binop: 1;
|
|
448
|
+
};
|
|
449
|
+
_break: TokenType & {
|
|
450
|
+
label: "break";
|
|
451
|
+
keyword: "break";
|
|
452
|
+
};
|
|
453
|
+
_case: TokenType & {
|
|
454
|
+
label: "case";
|
|
455
|
+
keyword: "case";
|
|
456
|
+
};
|
|
457
|
+
_catch: TokenType & {
|
|
458
|
+
label: "catch";
|
|
459
|
+
keyword: "catch";
|
|
460
|
+
};
|
|
461
|
+
_continue: TokenType & {
|
|
462
|
+
label: "continue";
|
|
463
|
+
keyword: "continue";
|
|
464
|
+
};
|
|
465
|
+
_debugger: TokenType & {
|
|
466
|
+
label: "debugger";
|
|
467
|
+
keyword: "debugger";
|
|
468
|
+
};
|
|
469
|
+
_default: TokenType & {
|
|
470
|
+
label: "default";
|
|
471
|
+
keyword: "default";
|
|
472
|
+
};
|
|
473
|
+
_do: TokenType & {
|
|
474
|
+
label: "do";
|
|
475
|
+
keyword: "do";
|
|
476
|
+
isLoop: true;
|
|
477
|
+
};
|
|
478
|
+
_else: TokenType & {
|
|
479
|
+
label: "else";
|
|
480
|
+
keyword: "else";
|
|
481
|
+
};
|
|
482
|
+
_finally: TokenType & {
|
|
483
|
+
label: "finally";
|
|
484
|
+
keyword: "finally";
|
|
485
|
+
};
|
|
486
|
+
_for: TokenType & {
|
|
487
|
+
label: "for";
|
|
488
|
+
keyword: "for";
|
|
489
|
+
isLoop: true;
|
|
490
|
+
};
|
|
491
|
+
_function: TokenType & {
|
|
492
|
+
label: "function";
|
|
493
|
+
keyword: "function";
|
|
494
|
+
};
|
|
495
|
+
_if: TokenType & {
|
|
496
|
+
label: "if";
|
|
497
|
+
keyword: "if";
|
|
498
|
+
};
|
|
499
|
+
_return: TokenType & {
|
|
500
|
+
label: "return";
|
|
501
|
+
keyword: "return";
|
|
502
|
+
};
|
|
503
|
+
_switch: TokenType & {
|
|
504
|
+
label: "switch";
|
|
505
|
+
keyword: "switch";
|
|
506
|
+
};
|
|
507
|
+
_throw: TokenType & {
|
|
508
|
+
label: "throw";
|
|
509
|
+
keyword: "throw";
|
|
510
|
+
};
|
|
511
|
+
_try: TokenType & {
|
|
512
|
+
label: "try";
|
|
513
|
+
keyword: "try";
|
|
514
|
+
};
|
|
515
|
+
_var: TokenType & {
|
|
516
|
+
label: "var";
|
|
517
|
+
keyword: "var";
|
|
518
|
+
};
|
|
519
|
+
_const: TokenType & {
|
|
520
|
+
label: "const";
|
|
521
|
+
keyword: "const";
|
|
522
|
+
};
|
|
523
|
+
_while: TokenType & {
|
|
524
|
+
label: "while";
|
|
525
|
+
keyword: "while";
|
|
526
|
+
isLoop: true;
|
|
527
|
+
};
|
|
528
|
+
_with: TokenType & {
|
|
529
|
+
label: "with";
|
|
530
|
+
keyword: "with";
|
|
531
|
+
};
|
|
532
|
+
_new: TokenType & {
|
|
533
|
+
label: "new";
|
|
534
|
+
keyword: "new";
|
|
535
|
+
};
|
|
536
|
+
_this: TokenType & {
|
|
537
|
+
label: "this";
|
|
538
|
+
keyword: "this";
|
|
539
|
+
};
|
|
540
|
+
_super: TokenType & {
|
|
541
|
+
label: "super";
|
|
542
|
+
keyword: "super";
|
|
543
|
+
};
|
|
544
|
+
_class: TokenType & {
|
|
545
|
+
label: "class";
|
|
546
|
+
keyword: "class";
|
|
547
|
+
};
|
|
548
|
+
_extends: TokenType & {
|
|
549
|
+
label: "extends";
|
|
550
|
+
keyword: "extends";
|
|
551
|
+
};
|
|
552
|
+
_export: TokenType & {
|
|
553
|
+
label: "export";
|
|
554
|
+
keyword: "export";
|
|
555
|
+
};
|
|
556
|
+
_import: TokenType & {
|
|
557
|
+
label: "import";
|
|
558
|
+
keyword: "import";
|
|
559
|
+
};
|
|
560
|
+
_null: TokenType & {
|
|
561
|
+
label: "null";
|
|
562
|
+
keyword: "null";
|
|
563
|
+
};
|
|
564
|
+
_true: TokenType & {
|
|
565
|
+
label: "true";
|
|
566
|
+
keyword: "true";
|
|
567
|
+
};
|
|
568
|
+
_false: TokenType & {
|
|
569
|
+
label: "false";
|
|
570
|
+
keyword: "false";
|
|
571
|
+
};
|
|
572
|
+
_in: TokenType & {
|
|
573
|
+
label: "in";
|
|
574
|
+
keyword: "in";
|
|
575
|
+
binop: 7;
|
|
576
|
+
};
|
|
577
|
+
_instanceof: TokenType & {
|
|
578
|
+
label: "instanceof";
|
|
579
|
+
keyword: "instanceof";
|
|
580
|
+
binop: 7;
|
|
581
|
+
};
|
|
582
|
+
_typeof: TokenType & {
|
|
583
|
+
label: "typeof";
|
|
584
|
+
keyword: "typeof";
|
|
585
|
+
prefix: true;
|
|
586
|
+
};
|
|
587
|
+
_void: TokenType & {
|
|
588
|
+
label: "void";
|
|
589
|
+
keyword: "void";
|
|
590
|
+
prefix: true;
|
|
591
|
+
};
|
|
592
|
+
_delete: TokenType & {
|
|
593
|
+
label: "delete";
|
|
594
|
+
keyword: "delete";
|
|
595
|
+
prefix: true;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* TypeScript-specific token types added by @sveltejs/acorn-typescript
|
|
600
|
+
*/
|
|
601
|
+
export interface AcornTypeScriptTokTypes {
|
|
602
|
+
jsxTagStart: TokenType & {
|
|
603
|
+
label: "jsxTagStart";
|
|
604
|
+
};
|
|
605
|
+
jsxTagEnd: TokenType & {
|
|
606
|
+
label: "jsxTagEnd";
|
|
607
|
+
};
|
|
608
|
+
jsxText: TokenType & {
|
|
609
|
+
label: "jsxText";
|
|
610
|
+
};
|
|
611
|
+
jsxName: TokenType & {
|
|
612
|
+
label: "jsxName";
|
|
613
|
+
};
|
|
614
|
+
at: TokenType & {
|
|
615
|
+
label: "@";
|
|
616
|
+
};
|
|
617
|
+
abstract: TokenType & {
|
|
618
|
+
label: "abstract";
|
|
619
|
+
};
|
|
620
|
+
as: TokenType & {
|
|
621
|
+
label: "as";
|
|
622
|
+
};
|
|
623
|
+
asserts: TokenType & {
|
|
624
|
+
label: "asserts";
|
|
625
|
+
};
|
|
626
|
+
assert: TokenType & {
|
|
627
|
+
label: "assert";
|
|
628
|
+
};
|
|
629
|
+
bigint: TokenType & {
|
|
630
|
+
label: "bigint";
|
|
631
|
+
};
|
|
632
|
+
declare: TokenType & {
|
|
633
|
+
label: "declare";
|
|
634
|
+
};
|
|
635
|
+
enum: TokenType & {
|
|
636
|
+
label: "enum";
|
|
637
|
+
};
|
|
638
|
+
global: TokenType & {
|
|
639
|
+
label: "global";
|
|
640
|
+
};
|
|
641
|
+
implements: TokenType & {
|
|
642
|
+
label: "implements";
|
|
643
|
+
};
|
|
644
|
+
infer: TokenType & {
|
|
645
|
+
label: "infer";
|
|
646
|
+
};
|
|
647
|
+
interface: TokenType & {
|
|
648
|
+
label: "interface";
|
|
649
|
+
};
|
|
650
|
+
intrinsic: TokenType & {
|
|
651
|
+
label: "intrinsic";
|
|
652
|
+
};
|
|
653
|
+
is: TokenType & {
|
|
654
|
+
label: "is";
|
|
655
|
+
};
|
|
656
|
+
keyof: TokenType & {
|
|
657
|
+
label: "keyof";
|
|
658
|
+
};
|
|
659
|
+
module: TokenType & {
|
|
660
|
+
label: "module";
|
|
661
|
+
};
|
|
662
|
+
namespace: TokenType & {
|
|
663
|
+
label: "namespace";
|
|
664
|
+
};
|
|
665
|
+
never: TokenType & {
|
|
666
|
+
label: "never";
|
|
667
|
+
};
|
|
668
|
+
out: TokenType & {
|
|
669
|
+
label: "out";
|
|
670
|
+
};
|
|
671
|
+
override: TokenType & {
|
|
672
|
+
label: "override";
|
|
673
|
+
};
|
|
674
|
+
private: TokenType & {
|
|
675
|
+
label: "private";
|
|
676
|
+
};
|
|
677
|
+
protected: TokenType & {
|
|
678
|
+
label: "protected";
|
|
679
|
+
};
|
|
680
|
+
public: TokenType & {
|
|
681
|
+
label: "public";
|
|
682
|
+
};
|
|
683
|
+
readonly: TokenType & {
|
|
684
|
+
label: "readonly";
|
|
685
|
+
};
|
|
686
|
+
require: TokenType & {
|
|
687
|
+
label: "require";
|
|
688
|
+
};
|
|
689
|
+
satisfies: TokenType & {
|
|
690
|
+
label: "satisfies";
|
|
691
|
+
};
|
|
692
|
+
symbol: TokenType & {
|
|
693
|
+
label: "symbol";
|
|
694
|
+
};
|
|
695
|
+
type: TokenType & {
|
|
696
|
+
label: "type";
|
|
697
|
+
};
|
|
698
|
+
unique: TokenType & {
|
|
699
|
+
label: "unique";
|
|
700
|
+
};
|
|
701
|
+
unknown: TokenType & {
|
|
702
|
+
label: "unknown";
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* TypeScript-specific token contexts added by @sveltejs/acorn-typescript
|
|
707
|
+
*/
|
|
708
|
+
export interface AcornTypeScriptTokContexts {
|
|
709
|
+
/** JSX opening tag context - `<` starting a JSX tag */
|
|
710
|
+
tc_oTag: TokContext & {
|
|
711
|
+
token: "<";
|
|
712
|
+
};
|
|
713
|
+
/** JSX closing tag context - `</` closing a JSX tag */
|
|
714
|
+
tc_cTag: TokContext & {
|
|
715
|
+
token: "</";
|
|
716
|
+
};
|
|
717
|
+
/** JSX expression context - `{` inside JSX for expressions */
|
|
718
|
+
tc_expr: TokContext & {
|
|
719
|
+
token: "{";
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Combined TypeScript extensions object
|
|
724
|
+
*/
|
|
725
|
+
export interface AcornTypeScriptExtensions {
|
|
726
|
+
tokTypes: AcornTypeScriptTokTypes;
|
|
727
|
+
tokContexts: AcornTypeScriptTokContexts;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Extended Parser instance with internal properties
|
|
731
|
+
*
|
|
732
|
+
* These properties are used internally by Acorn but not exposed in official types.
|
|
733
|
+
* They are accessed by Ripple's custom parser plugin for whitespace handling,
|
|
734
|
+
* JSX parsing, and other advanced features.
|
|
735
|
+
*/
|
|
736
|
+
export class Parser extends acorn.Parser {
|
|
737
|
+
/** Start position of the current token (0-indexed) */
|
|
738
|
+
start: number;
|
|
739
|
+
/** End position of the current token (0-indexed) */
|
|
740
|
+
end: number;
|
|
741
|
+
/** Current parsing position in input string (0-indexed) */
|
|
742
|
+
pos: number;
|
|
743
|
+
/** Current line number (1-indexed) */
|
|
744
|
+
curLine: number;
|
|
745
|
+
/** Position where the current line starts (0-indexed) */
|
|
746
|
+
lineStart: number;
|
|
747
|
+
/** Start location of current token */
|
|
748
|
+
startLoc: AST.Position;
|
|
749
|
+
/** End location of current token */
|
|
750
|
+
endLoc: AST.Position;
|
|
751
|
+
/** End position of the last token */
|
|
752
|
+
lastTokEnd: number;
|
|
753
|
+
/** Start position of the last token */
|
|
754
|
+
lastTokStart: number;
|
|
755
|
+
/** End location of the last token */
|
|
756
|
+
lastTokEndLoc: AST.Position;
|
|
757
|
+
/** Start location of the last token */
|
|
758
|
+
lastTokStartLoc: AST.Position;
|
|
759
|
+
/** Current token type */
|
|
760
|
+
type: TokenType;
|
|
761
|
+
/** Current token value (string for names, number for nums, etc.) */
|
|
762
|
+
value: string | number | RegExp | bigint | null;
|
|
763
|
+
/** The source code being parsed */
|
|
764
|
+
input: string;
|
|
765
|
+
/** Whether the current position expects an expression */
|
|
766
|
+
exprAllowed: boolean;
|
|
767
|
+
/** Whether the parser is in strict mode */
|
|
768
|
+
strict: boolean;
|
|
769
|
+
/** Whether we're inside a generator function */
|
|
770
|
+
inGenerator: boolean;
|
|
771
|
+
/** Whether we're inside an async function */
|
|
772
|
+
inAsync: boolean;
|
|
773
|
+
/** Whether we're inside a function */
|
|
774
|
+
inFunction: boolean;
|
|
775
|
+
/** Stack of label names for break/continue statements */
|
|
776
|
+
labels: Array<{
|
|
777
|
+
kind: string | null;
|
|
778
|
+
name?: string;
|
|
779
|
+
statementStart?: number;
|
|
780
|
+
}>;
|
|
781
|
+
/** Current scope flags stack */
|
|
782
|
+
scopeStack: Array<{
|
|
783
|
+
flags: number;
|
|
784
|
+
var: string[];
|
|
785
|
+
lexical: string[];
|
|
786
|
+
functions: string[];
|
|
787
|
+
}>;
|
|
788
|
+
/** Regular expression validation state */
|
|
789
|
+
regexpState?: any;
|
|
790
|
+
/** Whether we can use await keyword */
|
|
791
|
+
canAwait: boolean;
|
|
792
|
+
/** Position of await keyword (0 if not in async context) */
|
|
793
|
+
awaitPos: number;
|
|
794
|
+
/** Position of yield keyword (0 if not in generator context) */
|
|
795
|
+
yieldPos: number;
|
|
796
|
+
/** Position of await used as identifier (for error reporting) */
|
|
797
|
+
awaitIdentPos: number;
|
|
798
|
+
/** Whether current identifier contains escape sequences */
|
|
799
|
+
containsEsc: boolean;
|
|
800
|
+
/** Potential arrow function position */
|
|
801
|
+
potentialArrowAt: number;
|
|
802
|
+
/** Potential arrow in for-await position */
|
|
803
|
+
potentialArrowInForAwait: boolean;
|
|
804
|
+
/** Private name stack for class private fields validation */
|
|
805
|
+
privateNameStack: Array<{
|
|
806
|
+
declared: Record<string, any>;
|
|
807
|
+
used: Array<AST.Node>;
|
|
808
|
+
}>;
|
|
809
|
+
/** Undefined exports for module validation */
|
|
810
|
+
undefinedExports: Record<string, AST.Node>;
|
|
811
|
+
/** Token context stack for tokenizer state */
|
|
812
|
+
context: TokContext[];
|
|
813
|
+
/** Whether to preserve spaces in current context */
|
|
814
|
+
preserveSpace?: boolean;
|
|
815
|
+
/** Parser options (from constructor) */
|
|
816
|
+
options: Options;
|
|
817
|
+
/** ECMAScript version being parsed */
|
|
818
|
+
ecmaVersion: number;
|
|
819
|
+
/** Keywords regex for current ecmaVersion */
|
|
820
|
+
keywords: RegExp;
|
|
821
|
+
/** Reserved words regex */
|
|
822
|
+
reservedWords: RegExp;
|
|
823
|
+
/** Whether we're parsing a module */
|
|
824
|
+
inModule: boolean;
|
|
825
|
+
/**
|
|
826
|
+
* Finish current token with given type and optional value
|
|
827
|
+
* @see https://github.com/acornjs/acorn/blob/main/acorn/src/tokenize.js
|
|
828
|
+
*/
|
|
829
|
+
finishToken(type: TokenType, val?: string | number | RegExp | bigint): void;
|
|
830
|
+
readAtIdentifier(): void;
|
|
831
|
+
/**
|
|
832
|
+
* Read a token based on character code
|
|
833
|
+
* Called by nextToken() for each character
|
|
834
|
+
*/
|
|
835
|
+
readToken(code: number): void;
|
|
836
|
+
/**
|
|
837
|
+
* Read a word (identifier or keyword)
|
|
838
|
+
* @returns Token type (name or keyword)
|
|
839
|
+
*/
|
|
840
|
+
readWord(): TokenType;
|
|
841
|
+
/**
|
|
842
|
+
* Read word starting from current position
|
|
843
|
+
* @returns The word string
|
|
844
|
+
*/
|
|
845
|
+
readWord1(): string;
|
|
846
|
+
/** Read a number literal */
|
|
847
|
+
readNumber(startsWithDot: boolean): void;
|
|
848
|
+
/** Read a string literal */
|
|
849
|
+
readString(quote: number): void;
|
|
850
|
+
/** Read a template token */
|
|
851
|
+
readTmplToken(): void;
|
|
852
|
+
/** Read a regular expression literal */
|
|
853
|
+
readRegexp(): void;
|
|
854
|
+
/** Skip block comment, tracking line positions */
|
|
855
|
+
skipBlockComment(): void;
|
|
856
|
+
/** Skip line comment */
|
|
857
|
+
skipLineComment(startSkip: number): void;
|
|
858
|
+
/** Skip whitespace and comments */
|
|
859
|
+
skipSpace(): void;
|
|
860
|
+
/** Read and return the next token */
|
|
861
|
+
nextToken(): void;
|
|
862
|
+
/** Advance to next token (wrapper around nextToken) */
|
|
863
|
+
next(): void;
|
|
864
|
+
/**
|
|
865
|
+
* Get token from character code
|
|
866
|
+
* Main tokenizer dispatch based on first character
|
|
867
|
+
*/
|
|
868
|
+
getTokenFromCode(code: number): void;
|
|
869
|
+
/**
|
|
870
|
+
* Get current position as Position object
|
|
871
|
+
* @returns { line: number, column: number, index: number }
|
|
872
|
+
*/
|
|
873
|
+
curPosition(): AST.Position;
|
|
874
|
+
/**
|
|
875
|
+
* Finish building an operator token
|
|
876
|
+
* @param type Token type
|
|
877
|
+
* @param size Number of characters consumed
|
|
878
|
+
*/
|
|
879
|
+
finishOp(type: TokenType, size: number): TokenType;
|
|
880
|
+
/**
|
|
881
|
+
* Finish a node, setting its end position and type
|
|
882
|
+
* @template T Node type extending AST.Node
|
|
883
|
+
* @param node The node to finish
|
|
884
|
+
* @param type The node type string (e.g., "Identifier", "BinaryExpression")
|
|
885
|
+
* @returns The finished node
|
|
886
|
+
*/
|
|
887
|
+
finishNode<T extends AST.Node>(node: T, type: string): T;
|
|
888
|
+
/**
|
|
889
|
+
* Finish a node at a specific position
|
|
890
|
+
*/
|
|
891
|
+
finishNodeAt<T extends AST.Node>(node: T, type: string, pos: number, loc: AST.Position): T;
|
|
892
|
+
/**
|
|
893
|
+
* Start a new node at current position
|
|
894
|
+
*/
|
|
895
|
+
startNode(): AST.Node;
|
|
896
|
+
/**
|
|
897
|
+
* Start a new node at a specific position
|
|
898
|
+
* @param pos Start position
|
|
899
|
+
* @param loc Start location
|
|
900
|
+
* @returns A new node with specified start position
|
|
901
|
+
*/
|
|
902
|
+
startNodeAt(pos: number, loc: AST.Position): AST.Node;
|
|
903
|
+
/**
|
|
904
|
+
* Start a node at the same position as another node
|
|
905
|
+
* @param node The node to copy position from
|
|
906
|
+
* @returns A new node with copied start position
|
|
907
|
+
*/
|
|
908
|
+
startNodeAtNode(node: AST.Node): AST.Node;
|
|
909
|
+
/**
|
|
910
|
+
* Copy a node's position info
|
|
911
|
+
* @template T Node type
|
|
912
|
+
* @param node The node to copy
|
|
913
|
+
* @returns A shallow copy of the node
|
|
914
|
+
*/
|
|
915
|
+
copyNode<T extends AST.Node>(node: T): T;
|
|
916
|
+
/**
|
|
917
|
+
* Reset end location from another node
|
|
918
|
+
* @param node Node to update
|
|
919
|
+
*/
|
|
920
|
+
resetEndLocation(node: AST.Node): void;
|
|
921
|
+
/**
|
|
922
|
+
* Reset start location from another node
|
|
923
|
+
* @param node Node to update
|
|
924
|
+
* @param locationNode Node to copy from
|
|
925
|
+
*/
|
|
926
|
+
resetStartLocationFromNode(node: AST.Node, locationNode: AST.Node): void;
|
|
927
|
+
/**
|
|
928
|
+
* Raise a fatal error at given position
|
|
929
|
+
* @throws SyntaxError
|
|
930
|
+
*/
|
|
931
|
+
raise(pos: number, message: string): never;
|
|
932
|
+
/**
|
|
933
|
+
* Raise a recoverable error (warning that doesn't stop parsing)
|
|
934
|
+
*/
|
|
935
|
+
raiseRecoverable(pos: number, message: string): void;
|
|
936
|
+
/**
|
|
937
|
+
* Throw unexpected token error
|
|
938
|
+
* @param pos Optional position (defaults to current)
|
|
939
|
+
*/
|
|
940
|
+
unexpected(pos?: number): never;
|
|
941
|
+
/**
|
|
942
|
+
* Expect a specific token type, raise error if not found
|
|
943
|
+
* @param type Expected token type
|
|
944
|
+
*/
|
|
945
|
+
expect(type: TokenType): void;
|
|
946
|
+
/**
|
|
947
|
+
* Consume token if it matches, return true if consumed
|
|
948
|
+
* @param type Token type to eat
|
|
949
|
+
* @returns true if token was consumed
|
|
950
|
+
*/
|
|
951
|
+
eat(type: TokenType): boolean;
|
|
952
|
+
/**
|
|
953
|
+
* Check if current token matches type (alias for this.type === type)
|
|
954
|
+
* @param type Token type to match
|
|
955
|
+
*/
|
|
956
|
+
match(type: TokenType): boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Peek at character at position
|
|
959
|
+
* @deprecated Use charCodeAt instead
|
|
960
|
+
*/
|
|
961
|
+
charAt(pos: number): string;
|
|
962
|
+
/**
|
|
963
|
+
* Get character code at position in input
|
|
964
|
+
*/
|
|
965
|
+
charCodeAt(pos: number): number;
|
|
966
|
+
/**
|
|
967
|
+
* Check if current token is a contextual keyword
|
|
968
|
+
* @param name Keyword to check (e.g., "async", "of")
|
|
969
|
+
*/
|
|
970
|
+
isContextual(name: string): boolean;
|
|
971
|
+
/**
|
|
972
|
+
* Consume if current token is a contextual keyword
|
|
973
|
+
* @param name Keyword to consume
|
|
974
|
+
* @returns true if consumed
|
|
975
|
+
*/
|
|
976
|
+
eatContextual(name: string): boolean;
|
|
977
|
+
/**
|
|
978
|
+
* Expect a contextual keyword, raise error if not found
|
|
979
|
+
* @param name Expected keyword
|
|
980
|
+
*/
|
|
981
|
+
expectContextual(name: string): void;
|
|
982
|
+
/**
|
|
983
|
+
* Check if semicolon can be inserted at current position (ASI)
|
|
984
|
+
*/
|
|
985
|
+
canInsertSemicolon(): boolean;
|
|
986
|
+
/**
|
|
987
|
+
* Insert a semicolon if allowed by ASI rules
|
|
988
|
+
* returns true if semicolon was inserted
|
|
989
|
+
*/
|
|
990
|
+
insertSemicolon(): boolean;
|
|
991
|
+
/**
|
|
992
|
+
* Consume semicolon or insert via ASI
|
|
993
|
+
*/
|
|
994
|
+
semicolon(): void;
|
|
995
|
+
/**
|
|
996
|
+
* Handle trailing comma in lists
|
|
997
|
+
*/
|
|
998
|
+
afterTrailingComma(type: TokenType, notNext?: boolean): boolean;
|
|
999
|
+
/**
|
|
1000
|
+
* Enter a new scope
|
|
1001
|
+
* @param flags Scope flags (SCOPE_* constants)
|
|
1002
|
+
*/
|
|
1003
|
+
enterScope(flags: number): void;
|
|
1004
|
+
/** Exit current scope */
|
|
1005
|
+
exitScope(): void;
|
|
1006
|
+
/**
|
|
1007
|
+
* Declare a name in current scope
|
|
1008
|
+
*/
|
|
1009
|
+
declareName(name: string, bindingType: BindingType[keyof BindingType], pos: number): void;
|
|
1010
|
+
/** Get current scope */
|
|
1011
|
+
currentScope(): {
|
|
1012
|
+
flags: number;
|
|
1013
|
+
var: string[];
|
|
1014
|
+
lexical: string[];
|
|
1015
|
+
functions: string[];
|
|
1016
|
+
};
|
|
1017
|
+
/** Get current variable scope (for var declarations) */
|
|
1018
|
+
currentVarScope(): {
|
|
1019
|
+
flags: number;
|
|
1020
|
+
var: string[];
|
|
1021
|
+
lexical: string[];
|
|
1022
|
+
functions: string[];
|
|
1023
|
+
};
|
|
1024
|
+
/** Get current "this" scope */
|
|
1025
|
+
currentThisScope(): {
|
|
1026
|
+
flags: number;
|
|
1027
|
+
var: string[];
|
|
1028
|
+
lexical: string[];
|
|
1029
|
+
functions: string[];
|
|
1030
|
+
};
|
|
1031
|
+
/** Check if treating functions as var in current scope */
|
|
1032
|
+
treatFunctionsAsVarInScope(scope: any): boolean;
|
|
1033
|
+
/**
|
|
1034
|
+
* Get current token context
|
|
1035
|
+
* @returns Current context from stack
|
|
1036
|
+
*/
|
|
1037
|
+
curContext(): TokContext;
|
|
1038
|
+
/**
|
|
1039
|
+
* Update token context based on previous token
|
|
1040
|
+
* @param prevType Previous token type
|
|
1041
|
+
*/
|
|
1042
|
+
updateContext(prevType: TokenType): void;
|
|
1043
|
+
/**
|
|
1044
|
+
* Override the current context
|
|
1045
|
+
* @param context New context to push
|
|
1046
|
+
*/
|
|
1047
|
+
overrideContext(context: TokContext): void;
|
|
1048
|
+
/**
|
|
1049
|
+
* Look ahead one token without consuming
|
|
1050
|
+
* @returns Object with type and value of next token
|
|
1051
|
+
*/
|
|
1052
|
+
lookahead(): {
|
|
1053
|
+
type: TokenType;
|
|
1054
|
+
value: any;
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Get next token start position
|
|
1058
|
+
*/
|
|
1059
|
+
nextTokenStart(): number;
|
|
1060
|
+
/**
|
|
1061
|
+
* Get next token start since given position
|
|
1062
|
+
*/
|
|
1063
|
+
nextTokenStartSince(pos: number): number;
|
|
1064
|
+
/**
|
|
1065
|
+
* Look ahead at character code
|
|
1066
|
+
*/
|
|
1067
|
+
lookaheadCharCode(): number;
|
|
1068
|
+
/**
|
|
1069
|
+
* Parse an expression
|
|
1070
|
+
*/
|
|
1071
|
+
parseExpression(forInit?: ForInit, refDestructuringErrors?: DestructuringErrors): AST.Expression;
|
|
1072
|
+
/**
|
|
1073
|
+
* Parse maybe-assignment expression (handles = and op=)
|
|
1074
|
+
*/
|
|
1075
|
+
parseMaybeAssign(forInit?: ForInit, refDestructuringErrors?: DestructuringErrors, afterLeftParse?: (node: AST.Node, startPos: number, startLoc: AST.Position) => AST.Node): AST.Expression;
|
|
1076
|
+
/**
|
|
1077
|
+
* Parse maybe-conditional expression (?:)
|
|
1078
|
+
*/
|
|
1079
|
+
parseMaybeConditional(forInit?: ForInit, refDestructuringErrors?: DestructuringErrors): AST.Expression;
|
|
1080
|
+
/**
|
|
1081
|
+
* Parse expression with operators (handles precedence)
|
|
1082
|
+
*/
|
|
1083
|
+
parseExprOps(forInit?: ForInit, refDestructuringErrors?: DestructuringErrors): AST.Expression;
|
|
1084
|
+
/**
|
|
1085
|
+
* Parse expression with operator at given precedence
|
|
1086
|
+
*/
|
|
1087
|
+
parseExprOp(left: AST.Expression, leftStartPos: number, leftStartLoc: AST.Position, minPrec: number, forInit?: ForInit): AST.Expression;
|
|
1088
|
+
/**
|
|
1089
|
+
* Parse maybe-unary expression (prefix operators)
|
|
1090
|
+
*/
|
|
1091
|
+
parseMaybeUnary(refDestructuringErrors?: DestructuringErrors | null, sawUnary?: boolean, incDec?: boolean, forInit?: ForInit): AST.Expression;
|
|
1092
|
+
/**
|
|
1093
|
+
* Parse expression subscripts (member access, calls)
|
|
1094
|
+
*/
|
|
1095
|
+
parseExprSubscripts(refDestructuringErrors?: DestructuringErrors, forInit?: ForInit): AST.Expression;
|
|
1096
|
+
/**
|
|
1097
|
+
* Parse subscripts (., [], (), ?.)
|
|
1098
|
+
*/
|
|
1099
|
+
parseSubscripts(base: AST.Expression, startPos: number, startLoc: AST.Position, noCalls?: boolean, forInit?: ForInit): AST.Expression;
|
|
1100
|
+
parseSubscript(base: AST.Expression, startPos: number, startLoc: AST.Position, noCalls?: boolean, maybeAsyncArrow?: boolean, optionalChained?: boolean, forInit?: ForInit): AST.Expression;
|
|
1101
|
+
/**
|
|
1102
|
+
* Parse expression atom (literals, identifiers, etc.)
|
|
1103
|
+
*/
|
|
1104
|
+
parseExprAtom(refDestructuringErrors?: DestructuringErrors, forInit?: ForInit, forNew?: boolean): AST.Expression;
|
|
1105
|
+
/**
|
|
1106
|
+
* Parse a literal value (string, number, boolean, null, regex)
|
|
1107
|
+
* @param value The literal value
|
|
1108
|
+
* @returns Literal node
|
|
1109
|
+
*/
|
|
1110
|
+
parseLiteral(value: string | number | boolean | null | RegExp | bigint): AST.Literal;
|
|
1111
|
+
/**
|
|
1112
|
+
* Parse parenthesized expression, distinguishing arrow functions
|
|
1113
|
+
*/
|
|
1114
|
+
parseParenAndDistinguishExpression(canBeArrow?: boolean, forInit?: ForInit): AST.Expression;
|
|
1115
|
+
/** Parse parenthesized expression (just the expression) */
|
|
1116
|
+
parseParenExpression(): AST.Expression;
|
|
1117
|
+
/**
|
|
1118
|
+
* Parse item in parentheses (can be overridden for flow/ts)
|
|
1119
|
+
*/
|
|
1120
|
+
parseParenItem(item: AST.Node): AST.Node;
|
|
1121
|
+
/**
|
|
1122
|
+
* Parse arrow expression
|
|
1123
|
+
|
|
1124
|
+
*/
|
|
1125
|
+
parseArrowExpression(node: AST.Node, params: AST.Node[], isAsync?: boolean, forInit?: ForInit): AST.ArrowFunctionExpression;
|
|
1126
|
+
/**
|
|
1127
|
+
* Check if arrow should be parsed
|
|
1128
|
+
*/
|
|
1129
|
+
shouldParseArrow(exprList: AST.Node[]): boolean;
|
|
1130
|
+
/**
|
|
1131
|
+
* Parse spread element (...expr)
|
|
1132
|
+
*/
|
|
1133
|
+
parseSpread(refDestructuringErrors?: DestructuringErrors): AST.SpreadElement;
|
|
1134
|
+
/**
|
|
1135
|
+
* Parse rest binding pattern (...pattern)
|
|
1136
|
+
* @returns RestElement node
|
|
1137
|
+
*/
|
|
1138
|
+
parseRestBinding(): AST.RestElement;
|
|
1139
|
+
/**
|
|
1140
|
+
* Parse 'new' expression
|
|
1141
|
+
* @returns NewExpression or MetaProperty (new.target)
|
|
1142
|
+
*/
|
|
1143
|
+
parseNew(): AST.NewExpression | AST.MetaProperty;
|
|
1144
|
+
/**
|
|
1145
|
+
* Parse dynamic import expression
|
|
1146
|
+
* @param forNew Whether in new expression context
|
|
1147
|
+
*/
|
|
1148
|
+
parseExprImport(forNew?: boolean): AST.ImportExpression | AST.MetaProperty;
|
|
1149
|
+
/**
|
|
1150
|
+
* Parse dynamic import call
|
|
1151
|
+
* @param node Import expression node
|
|
1152
|
+
*/
|
|
1153
|
+
parseDynamicImport(node: AST.Node): AST.ImportExpression;
|
|
1154
|
+
/**
|
|
1155
|
+
* Parse import.meta
|
|
1156
|
+
* @param node MetaProperty node
|
|
1157
|
+
*/
|
|
1158
|
+
parseImportMeta(node: AST.Node): AST.MetaProperty;
|
|
1159
|
+
/** Parse yield expression */
|
|
1160
|
+
parseYield(forInit?: ForInit): AST.YieldExpression;
|
|
1161
|
+
/** Parse await expression */
|
|
1162
|
+
parseAwait(forInit?: ForInit): AST.AwaitExpression;
|
|
1163
|
+
/**
|
|
1164
|
+
* Parse template literal
|
|
1165
|
+
* @param isTagged Whether this is a tagged template
|
|
1166
|
+
*/
|
|
1167
|
+
parseTemplate(isTagged?: {
|
|
1168
|
+
start: number;
|
|
1169
|
+
}): AST.TemplateLiteral;
|
|
1170
|
+
/**
|
|
1171
|
+
* Parse template element
|
|
1172
|
+
* @param options { isTagged: boolean }
|
|
1173
|
+
*/
|
|
1174
|
+
parseTemplateElement(options: {
|
|
1175
|
+
isTagged: boolean;
|
|
1176
|
+
}): AST.TemplateElement;
|
|
1177
|
+
/**
|
|
1178
|
+
* Parse an identifier
|
|
1179
|
+
*/
|
|
1180
|
+
parseIdent(liberal?: boolean): AST.Identifier;
|
|
1181
|
+
/**
|
|
1182
|
+
* Parse identifier node (internal, doesn't consume token)
|
|
1183
|
+
* @returns Partial identifier node
|
|
1184
|
+
*/
|
|
1185
|
+
parseIdentNode(): AST.Node;
|
|
1186
|
+
/**
|
|
1187
|
+
* Parse private identifier (#name)
|
|
1188
|
+
* @returns PrivateIdentifier node
|
|
1189
|
+
*/
|
|
1190
|
+
parsePrivateIdent(): AST.PrivateIdentifier;
|
|
1191
|
+
/**
|
|
1192
|
+
* Check if identifier is unreserved
|
|
1193
|
+
* @param ref Node with name, start, end
|
|
1194
|
+
*/
|
|
1195
|
+
checkUnreserved(ref: {
|
|
1196
|
+
name: string;
|
|
1197
|
+
start: number;
|
|
1198
|
+
end: number;
|
|
1199
|
+
}): void;
|
|
1200
|
+
/**
|
|
1201
|
+
* Parse object expression or pattern
|
|
1202
|
+
* @param isPattern Whether parsing a pattern
|
|
1203
|
+
* @param refDestructuringErrors Error collector
|
|
1204
|
+
* @returns ObjectExpression or ObjectPattern
|
|
1205
|
+
*/
|
|
1206
|
+
parseObj(isPattern?: boolean, refDestructuringErrors?: DestructuringErrors): AST.ObjectExpression | AST.ObjectPattern;
|
|
1207
|
+
/**
|
|
1208
|
+
* Parse property in object literal
|
|
1209
|
+
* @param isPattern Whether parsing a pattern
|
|
1210
|
+
* @param refDestructuringErrors Error collector
|
|
1211
|
+
* @returns Property node
|
|
1212
|
+
*/
|
|
1213
|
+
parseProperty(isPattern: boolean, refDestructuringErrors?: DestructuringErrors): AST.Property | AST.SpreadElement;
|
|
1214
|
+
/**
|
|
1215
|
+
* Parse property name (identifier, string, number, computed)
|
|
1216
|
+
* @param prop Property node to update
|
|
1217
|
+
* @returns The key expression
|
|
1218
|
+
*/
|
|
1219
|
+
parsePropertyName(prop: AST.Node): AST.Expression | AST.PrivateIdentifier;
|
|
1220
|
+
/**
|
|
1221
|
+
* Parse property value
|
|
1222
|
+
* @param prop Property node
|
|
1223
|
+
* @param isPattern Whether parsing pattern
|
|
1224
|
+
* @param isGenerator Whether generator method
|
|
1225
|
+
* @param isAsync Whether async method
|
|
1226
|
+
* @param startPos Start position
|
|
1227
|
+
* @param startLoc Start location
|
|
1228
|
+
* @param refDestructuringErrors Error collector
|
|
1229
|
+
* @param containsEsc Whether key contains escapes
|
|
1230
|
+
*/
|
|
1231
|
+
parsePropertyValue(prop: AST.Node, isPattern: boolean, isGenerator: boolean, isAsync: boolean, startPos: number, startLoc: AST.Position, refDestructuringErrors?: DestructuringErrors, containsEsc?: boolean): void;
|
|
1232
|
+
/**
|
|
1233
|
+
* Get property kind from name
|
|
1234
|
+
* @param prop Property node
|
|
1235
|
+
* @returns "init", "get", or "set"
|
|
1236
|
+
*/
|
|
1237
|
+
getPropertyKind(prop: AST.Node): "init" | "get" | "set";
|
|
1238
|
+
/**
|
|
1239
|
+
* Parse expression list (array elements, call arguments)
|
|
1240
|
+
* @param close Closing token type
|
|
1241
|
+
* @param allowTrailingComma Whether trailing comma allowed
|
|
1242
|
+
* @param allowEmpty Whether empty slots allowed
|
|
1243
|
+
* @param refDestructuringErrors Error collector
|
|
1244
|
+
* @returns Array of expressions
|
|
1245
|
+
*/
|
|
1246
|
+
parseExprList(close: TokenType, allowTrailingComma?: boolean, allowEmpty?: boolean, refDestructuringErrors?: DestructuringErrors): (AST.Expression | null)[];
|
|
1247
|
+
/**
|
|
1248
|
+
* Parse binding list (pattern elements)
|
|
1249
|
+
* @param close Closing token type
|
|
1250
|
+
* @param allowEmpty Whether empty slots allowed
|
|
1251
|
+
* @param allowTrailingComma Whether trailing comma allowed
|
|
1252
|
+
* @param allowModifiers Whether modifiers allowed (TS)
|
|
1253
|
+
*/
|
|
1254
|
+
parseBindingList(close: TokenType, allowEmpty?: boolean, allowTrailingComma?: boolean, allowModifiers?: boolean): AST.Pattern[];
|
|
1255
|
+
/**
|
|
1256
|
+
* Parse binding atom (identifier or pattern)
|
|
1257
|
+
* @returns Pattern node
|
|
1258
|
+
*/
|
|
1259
|
+
parseBindingAtom(): AST.Pattern;
|
|
1260
|
+
/**
|
|
1261
|
+
* Parse top level program
|
|
1262
|
+
* @param node Program node to populate
|
|
1263
|
+
* @returns Completed Program node
|
|
1264
|
+
*/
|
|
1265
|
+
parseTopLevel(node: AST.Program): AST.Program;
|
|
1266
|
+
parseTemplateBody(body: (AST.Statement | AST.Node)[]): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Parse a statement
|
|
1269
|
+
* @param context Statement context ("for", "if", "label", etc.)
|
|
1270
|
+
* @param topLevel Whether at top level
|
|
1271
|
+
* @param exports Export set for module
|
|
1272
|
+
* @returns Statement node
|
|
1273
|
+
*/
|
|
1274
|
+
parseStatement(context?: string | null, topLevel?: boolean, exports?: AST.ExportSpecifier): AST.ExpressionStatement | AST.Statement | AST.GTSDefineStatement;
|
|
1275
|
+
parseBlock(createNewLexicalScope?: boolean, node?: AST.BlockStatement, exitStrict?: boolean): AST.BlockStatement;
|
|
1276
|
+
/** Parse empty statement (;) */
|
|
1277
|
+
parseEmptyStatement(node: AST.Node): AST.EmptyStatement;
|
|
1278
|
+
/** Parse expression statement */
|
|
1279
|
+
parseExpressionStatement(node: AST.Node, expr: AST.Expression): AST.ExpressionStatement;
|
|
1280
|
+
/** Parse labeled statement */
|
|
1281
|
+
parseLabeledStatement(node: AST.Node, maybeName: string, expr: AST.Expression, context?: string): AST.LabeledStatement;
|
|
1282
|
+
/** Parse if statement */
|
|
1283
|
+
parseIfStatement(node: AST.Node): AST.IfStatement;
|
|
1284
|
+
/** Parse switch statement */
|
|
1285
|
+
parseSwitchStatement(node: AST.Node): AST.SwitchStatement;
|
|
1286
|
+
/** Parse while statement */
|
|
1287
|
+
parseWhileStatement(node: AST.Node): AST.WhileStatement;
|
|
1288
|
+
/** Parse do-while statement */
|
|
1289
|
+
parseDoStatement(node: AST.Node): AST.DoWhileStatement;
|
|
1290
|
+
/** Parse for statement (all variants) */
|
|
1291
|
+
parseForStatement(node: AST.ForStatement | AST.ForInStatement | AST.ForOfStatement): AST.ForStatement | AST.ForInStatement | AST.ForOfStatement;
|
|
1292
|
+
parseForAfterInitWithIndex(node: AST.ForStatement | AST.ForInStatement | AST.ForOfStatement, init: AST.VariableDeclaration, awaitAt: number): AST.ForStatement | AST.ForInStatement | AST.ForOfStatement;
|
|
1293
|
+
parseForInWithIndex(node: AST.ForInStatement | AST.ForOfStatement, init: AST.VariableDeclaration | AST.Pattern): AST.ForInStatement | AST.ForOfStatement;
|
|
1294
|
+
/**
|
|
1295
|
+
* Parse regular for loop
|
|
1296
|
+
* @param node For statement node
|
|
1297
|
+
* @param init Initializer expression
|
|
1298
|
+
*/
|
|
1299
|
+
parseFor(node: AST.Node, init: AST.Node | null): AST.ForStatement;
|
|
1300
|
+
/**
|
|
1301
|
+
* Parse for-in loop
|
|
1302
|
+
* @param node For statement node
|
|
1303
|
+
* @param init Left-hand binding
|
|
1304
|
+
*/
|
|
1305
|
+
parseForIn(node: AST.Node, init: AST.Node): AST.ForInStatement;
|
|
1306
|
+
/** Parse break statement */
|
|
1307
|
+
parseBreakContinueStatement(node: AST.Node, keyword: string): AST.BreakStatement | AST.ContinueStatement;
|
|
1308
|
+
/** Parse return statement */
|
|
1309
|
+
parseReturnStatement(node: AST.Node): AST.ReturnStatement;
|
|
1310
|
+
/** Parse throw statement */
|
|
1311
|
+
parseThrowStatement(node: AST.Node): AST.ThrowStatement;
|
|
1312
|
+
/** Parse try statement */
|
|
1313
|
+
parseTryStatement(node: AST.TryStatement): AST.TryStatement;
|
|
1314
|
+
/**
|
|
1315
|
+
* Parse catch clause parameter
|
|
1316
|
+
* @returns Pattern node for catch param
|
|
1317
|
+
*/
|
|
1318
|
+
parseCatchClauseParam(): AST.Pattern;
|
|
1319
|
+
/** Parse with statement */
|
|
1320
|
+
parseWithStatement(node: AST.Node): AST.WithStatement;
|
|
1321
|
+
/** Parse debugger statement */
|
|
1322
|
+
parseDebuggerStatement(node: AST.Node): AST.DebuggerStatement;
|
|
1323
|
+
/** Parse variable statement (var, let, const) */
|
|
1324
|
+
parseVarStatement(node: AST.Node, kind: string): AST.VariableDeclaration;
|
|
1325
|
+
/**
|
|
1326
|
+
* Parse variable declarations
|
|
1327
|
+
* @param node Declaration node
|
|
1328
|
+
* @param isFor Whether in for-loop initializer
|
|
1329
|
+
* @param kind "var", "let", "const", "using", or "await using"
|
|
1330
|
+
* @returns VariableDeclaration node
|
|
1331
|
+
*/
|
|
1332
|
+
parseVar(node: AST.Node, isFor: boolean, kind: string): AST.VariableDeclaration;
|
|
1333
|
+
/**
|
|
1334
|
+
* Parse variable ID (identifier or pattern)
|
|
1335
|
+
* @param decl Declarator node
|
|
1336
|
+
* @param kind Variable kind
|
|
1337
|
+
*/
|
|
1338
|
+
parseVarId(decl: AST.Node, kind: string): void;
|
|
1339
|
+
/** Check if current token starts 'let' declaration */
|
|
1340
|
+
isLet(context?: string): boolean;
|
|
1341
|
+
/** Check if current token starts 'using' declaration */
|
|
1342
|
+
isUsing?(isFor?: boolean): boolean;
|
|
1343
|
+
/** Check if current token starts 'await using' declaration */
|
|
1344
|
+
isAwaitUsing?(isFor?: boolean): boolean;
|
|
1345
|
+
/**
|
|
1346
|
+
* Parse function declaration or expression
|
|
1347
|
+
*/
|
|
1348
|
+
parseFunction(node: AST.Node, statement: number, allowExpressionBody?: boolean, isAsync?: boolean, forInit?: ForInit): AST.FunctionDeclaration | AST.FunctionExpression;
|
|
1349
|
+
/** Parse function statement */
|
|
1350
|
+
parseFunctionStatement(node: AST.Node, isAsync?: boolean, declarationPosition?: boolean): AST.FunctionDeclaration;
|
|
1351
|
+
/**
|
|
1352
|
+
* Parse function parameters into node.params
|
|
1353
|
+
* @param node Function node to populate
|
|
1354
|
+
*/
|
|
1355
|
+
parseFunctionParams(node: AST.Node): void;
|
|
1356
|
+
/**
|
|
1357
|
+
* Parse function body
|
|
1358
|
+
*/
|
|
1359
|
+
parseFunctionBody(node: AST.Node, isArrowFunction: boolean, isMethod: boolean, forInit?: ForInit): void;
|
|
1360
|
+
/** Initialize function node properties */
|
|
1361
|
+
initFunction(node: AST.Node): void;
|
|
1362
|
+
/** Check for yield/await in default parameters */
|
|
1363
|
+
checkYieldAwaitInDefaultParams(): void;
|
|
1364
|
+
/** Check if async function */
|
|
1365
|
+
isAsyncFunction(): boolean;
|
|
1366
|
+
/**
|
|
1367
|
+
* Parse class declaration or expression
|
|
1368
|
+
* @param node Class node
|
|
1369
|
+
* @param isStatement true, "nullableID", or false
|
|
1370
|
+
*/
|
|
1371
|
+
parseClass(node: AST.Node, isStatement: boolean | "nullableID"): AST.ClassDeclaration | AST.ClassExpression;
|
|
1372
|
+
/** Parse class ID (name) */
|
|
1373
|
+
parseClassId(node: AST.Node, isStatement: boolean | "nullableID"): void;
|
|
1374
|
+
/** Parse class superclass */
|
|
1375
|
+
parseClassSuper(node: AST.Node): void;
|
|
1376
|
+
/** Enter class body scope */
|
|
1377
|
+
enterClassBody(): Record<string, any>;
|
|
1378
|
+
/** Exit class body scope */
|
|
1379
|
+
exitClassBody(): void;
|
|
1380
|
+
/**
|
|
1381
|
+
* Parse class element (method, field, static block)
|
|
1382
|
+
* @param constructorAllowsSuper Whether constructor can call super
|
|
1383
|
+
*/
|
|
1384
|
+
parseClassElement(constructorAllowsSuper: boolean): AST.MethodDefinition | AST.PropertyDefinition | AST.StaticBlock | null;
|
|
1385
|
+
/** Parse class element name */
|
|
1386
|
+
parseClassElementName(element: AST.Node): void;
|
|
1387
|
+
/** Parse class static block */
|
|
1388
|
+
parseClassStaticBlock(node: AST.Node): AST.StaticBlock;
|
|
1389
|
+
/** Parse class method */
|
|
1390
|
+
parseClassMethod(method: AST.Node, isGenerator: boolean, isAsync: boolean, allowDirectSuper: boolean): AST.MethodDefinition;
|
|
1391
|
+
/** Parse class field */
|
|
1392
|
+
parseClassField(field: AST.Node): AST.PropertyDefinition;
|
|
1393
|
+
/** Check if class element name start */
|
|
1394
|
+
isClassElementNameStart(): boolean;
|
|
1395
|
+
/**
|
|
1396
|
+
* Parse method definition
|
|
1397
|
+
* @param isGenerator Whether generator method
|
|
1398
|
+
* @param isAsync Whether async method
|
|
1399
|
+
* @param allowDirectSuper Whether super() allowed
|
|
1400
|
+
*/
|
|
1401
|
+
parseMethod(isGenerator: boolean, isAsync?: boolean, allowDirectSuper?: boolean): AST.FunctionExpression;
|
|
1402
|
+
/** Parse import declaration */
|
|
1403
|
+
parseImport(node: AST.Node): AST.ImportDeclaration;
|
|
1404
|
+
/** Parse import specifiers */
|
|
1405
|
+
parseImportSpecifiers(): AST.ImportSpecifier[];
|
|
1406
|
+
/** Parse single import specifier */
|
|
1407
|
+
parseImportSpecifier(): AST.ImportSpecifier;
|
|
1408
|
+
/** Parse module export name (identifier or string) */
|
|
1409
|
+
parseModuleExportName(): AST.Identifier | AST.Literal;
|
|
1410
|
+
/** Parse export declaration */
|
|
1411
|
+
parseExport(node: AST.Node, exports?: any): AST.ExportNamedDeclaration | AST.ExportDefaultDeclaration | AST.ExportAllDeclaration;
|
|
1412
|
+
/** Parse export specifiers */
|
|
1413
|
+
parseExportSpecifiers(exports?: any): AST.ExportSpecifier[];
|
|
1414
|
+
/** Parse export default declaration */
|
|
1415
|
+
parseExportDefaultDeclaration(): AST.Declaration | AST.Expression;
|
|
1416
|
+
/** Check if export statement should be parsed */
|
|
1417
|
+
shouldParseExportStatement(): boolean;
|
|
1418
|
+
/** Parse export declaration body */
|
|
1419
|
+
parseExportDeclaration(node: AST.Node): AST.Declaration;
|
|
1420
|
+
/**
|
|
1421
|
+
* Convert expression to assignable pattern
|
|
1422
|
+
* @param node Expression to convert
|
|
1423
|
+
* @param isBinding Whether binding pattern
|
|
1424
|
+
* @param refDestructuringErrors Error collector
|
|
1425
|
+
*/
|
|
1426
|
+
toAssignable(node: AST.Node, isBinding?: boolean, refDestructuringErrors?: DestructuringErrors): AST.Pattern;
|
|
1427
|
+
/**
|
|
1428
|
+
* Convert expression list to assignable list
|
|
1429
|
+
* @param exprList Expression list
|
|
1430
|
+
* @param isBinding Whether binding patterns
|
|
1431
|
+
*/
|
|
1432
|
+
toAssignableList(exprList: AST.Node[], isBinding: boolean): AST.Pattern[];
|
|
1433
|
+
/**
|
|
1434
|
+
* Parse maybe-default pattern (pattern = defaultValue)
|
|
1435
|
+
* @param startPos Start position
|
|
1436
|
+
* @param startLoc Start location
|
|
1437
|
+
* @param left Left-hand pattern
|
|
1438
|
+
*/
|
|
1439
|
+
parseMaybeDefault(startPos: number, startLoc: AST.Position, left?: AST.Node): AST.Pattern;
|
|
1440
|
+
/**
|
|
1441
|
+
* Check left-value pattern (for destructuring)
|
|
1442
|
+
*/
|
|
1443
|
+
checkLValPattern(node: AST.Node, bindingType?: BindingType[keyof BindingType], checkClashes?: Record<string, boolean>): void;
|
|
1444
|
+
/**
|
|
1445
|
+
* Check left-value simple (identifier or member expression)
|
|
1446
|
+
*/
|
|
1447
|
+
checkLValSimple(expr: AST.Node, bindingType?: BindingType[keyof BindingType], checkClashes?: Record<string, boolean>): void;
|
|
1448
|
+
/**
|
|
1449
|
+
* Check left-value inner pattern
|
|
1450
|
+
* @param node Pattern node
|
|
1451
|
+
* @param bindingType Binding type constant
|
|
1452
|
+
* @param checkClashes Clash detection object
|
|
1453
|
+
*/
|
|
1454
|
+
checkLValInnerPattern(node: AST.Node, bindingType?: BindingType[keyof BindingType], checkClashes?: Record<string, boolean>): void;
|
|
1455
|
+
/**
|
|
1456
|
+
* Check expression errors
|
|
1457
|
+
* @param refDestructuringErrors Error collector
|
|
1458
|
+
* @param andThrow Whether to throw on error
|
|
1459
|
+
* @returns Whether there were errors
|
|
1460
|
+
*/
|
|
1461
|
+
checkExpressionErrors(refDestructuringErrors: DestructuringErrors | null, andThrow?: boolean): boolean;
|
|
1462
|
+
/**
|
|
1463
|
+
* Check if expression is simple assign target
|
|
1464
|
+
* @param expr Expression to check
|
|
1465
|
+
*/
|
|
1466
|
+
isSimpleAssignTarget(expr: AST.Node): boolean;
|
|
1467
|
+
/**
|
|
1468
|
+
* Try to parse, returning result with error info if failed
|
|
1469
|
+
* @param fn Parsing function to try
|
|
1470
|
+
* @returns Result with node, error, thrown, aborted, failState
|
|
1471
|
+
*/
|
|
1472
|
+
tryParse<T>(fn: () => T): {
|
|
1473
|
+
node: T | null;
|
|
1474
|
+
error: Error | null;
|
|
1475
|
+
thrown: boolean;
|
|
1476
|
+
aborted: boolean;
|
|
1477
|
+
failState: any;
|
|
1478
|
+
};
|
|
1479
|
+
getElementName(node?: AST.Node): string | null;
|
|
1480
|
+
/**
|
|
1481
|
+
* The constructor/class type for the extended Ripple parser.
|
|
1482
|
+
* This represents the static side of the parser class after extending with plugins.
|
|
1483
|
+
*/
|
|
1484
|
+
/** Built-in token types */
|
|
1485
|
+
static tokTypes: TokTypes;
|
|
1486
|
+
/** Built-in token contexts */
|
|
1487
|
+
static tokContexts: TokContexts;
|
|
1488
|
+
/** TypeScript extensions when using acorn-typescript */
|
|
1489
|
+
static acornTypeScript: AcornTypeScriptExtensions;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
//#endregion
|
|
612
1493
|
//#region src/config.d.ts
|
|
613
1494
|
interface GtsConfig extends TranspileOption {}
|
|
614
1495
|
type ReadFileFn = (path: string, encoding: "utf8") => string;
|
|
@@ -636,4 +1517,4 @@ declare function resolveGtsConfigSync(filePath: string, inlineConfig: GtsConfig,
|
|
|
636
1517
|
declare function transpile(source: string, filename: string, option: TranspileOption): TranspileResult;
|
|
637
1518
|
declare function transpileForVolar(source: string, filename: string, option: TranspileOption): VolarMappingResult;
|
|
638
1519
|
//#endregion
|
|
639
|
-
export { type GtsConfig, type ParseLooseOptions as GtsParseLooseOptions, type ParseOptions as GtsParseOptions, GtsTranspilerError, type PathModule, type ResolveGtsConfigAsyncOptions, type ResolveGtsConfigSyncOptions, type TranspileOption, type TranspileResult, type VolarMappingResult, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|
|
1520
|
+
export { type AST, type GtsConfig, type ParseLooseOptions as GtsParseLooseOptions, type ParseOptions as GtsParseOptions, GtsTranspilerError, type PathModule, type ResolveGtsConfigAsyncOptions, type ResolveGtsConfigSyncOptions, type TranspileOption, type TranspileResult, type VolarMappingResult, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|