@aljazmc/syntax 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,604 @@
1
+ import type { Comment } from "./scanner.js";
2
+ export interface Attached extends Comment {
3
+ placement: "dangling" | "leading" | "trailing";
4
+ }
5
+ interface Base {
6
+ start: number;
7
+ end: number;
8
+ comments?: Attached[];
9
+ /** Set when the source wrapped the node in parentheses. */
10
+ parenthesized?: boolean;
11
+ }
12
+ type Of<T extends string, F = object> = Base & {
13
+ type: T;
14
+ } & F;
15
+ export type Accessibility = "private" | "protected" | "public";
16
+ interface Modifiers {
17
+ accessibility?: Accessibility;
18
+ abstract?: boolean;
19
+ declare?: boolean;
20
+ override?: boolean;
21
+ readonly?: boolean;
22
+ static?: boolean;
23
+ }
24
+ interface FunctionParts {
25
+ id: Identifier | null;
26
+ params: Node[];
27
+ body: Node | null;
28
+ async: boolean;
29
+ generator: boolean;
30
+ typeParameters: TypeParameters | null;
31
+ returnType: Node | null;
32
+ }
33
+ export type Program = Of<"Program", {
34
+ body: Node[];
35
+ directives: Node[];
36
+ }>;
37
+ export type Directive = Of<"Directive", {
38
+ value: StringLiteral;
39
+ }>;
40
+ export type ExpressionStatement = Of<"ExpressionStatement", {
41
+ expression: Node;
42
+ }>;
43
+ export type BlockStatement = Of<"BlockStatement", {
44
+ body: Node[];
45
+ directives: Node[];
46
+ }>;
47
+ export type EmptyStatement = Of<"EmptyStatement">;
48
+ export type DebuggerStatement = Of<"DebuggerStatement">;
49
+ export type ReturnStatement = Of<"ReturnStatement", {
50
+ argument: Node | null;
51
+ }>;
52
+ export type ThrowStatement = Of<"ThrowStatement", {
53
+ argument: Node;
54
+ }>;
55
+ export type BreakStatement = Of<"BreakStatement", {
56
+ label: Identifier | null;
57
+ }>;
58
+ export type ContinueStatement = Of<"ContinueStatement", {
59
+ label: Identifier | null;
60
+ }>;
61
+ export type LabeledStatement = Of<"LabeledStatement", {
62
+ label: Identifier;
63
+ body: Node;
64
+ }>;
65
+ export type IfStatement = Of<"IfStatement", {
66
+ test: Node;
67
+ consequent: Node;
68
+ alternate: Node | null;
69
+ }>;
70
+ export type SwitchStatement = Of<"SwitchStatement", {
71
+ discriminant: Node;
72
+ cases: SwitchCase[];
73
+ }>;
74
+ export type SwitchCase = Of<"SwitchCase", {
75
+ test: Node | null;
76
+ consequent: Node[];
77
+ }>;
78
+ export type WhileStatement = Of<"WhileStatement", {
79
+ test: Node;
80
+ body: Node;
81
+ }>;
82
+ export type DoWhileStatement = Of<"DoWhileStatement", {
83
+ test: Node;
84
+ body: Node;
85
+ }>;
86
+ export type ForStatement = Of<"ForStatement", {
87
+ init: Node | null;
88
+ test: Node | null;
89
+ update: Node | null;
90
+ body: Node;
91
+ }>;
92
+ export type ForInStatement = Of<"ForInStatement", {
93
+ left: Node;
94
+ right: Node;
95
+ body: Node;
96
+ }>;
97
+ export type ForOfStatement = Of<"ForOfStatement", {
98
+ left: Node;
99
+ right: Node;
100
+ body: Node;
101
+ await: boolean;
102
+ }>;
103
+ export type TryStatement = Of<"TryStatement", {
104
+ block: BlockStatement;
105
+ handler: CatchClause | null;
106
+ finalizer: BlockStatement | null;
107
+ }>;
108
+ export type CatchClause = Of<"CatchClause", {
109
+ param: Node | null;
110
+ body: BlockStatement;
111
+ }>;
112
+ export type WithStatement = Of<"WithStatement", {
113
+ object: Node;
114
+ body: Node;
115
+ }>;
116
+ export type VariableDeclaration = Of<"VariableDeclaration", {
117
+ kind: string;
118
+ declarations: VariableDeclarator[];
119
+ declare: boolean;
120
+ }>;
121
+ export type VariableDeclarator = Of<"VariableDeclarator", {
122
+ id: Node;
123
+ init: Node | null;
124
+ definite: boolean;
125
+ }>;
126
+ export type FunctionDeclaration = Of<"FunctionDeclaration", FunctionParts & {
127
+ declare: boolean;
128
+ }>;
129
+ export type ClassDeclaration = Of<"ClassDeclaration", ClassParts>;
130
+ export type ImportDeclaration = Of<"ImportDeclaration", {
131
+ specifiers: Node[];
132
+ source: StringLiteral;
133
+ attributes: Node[];
134
+ importKind: "type" | "typeof" | "value";
135
+ phase: string | null;
136
+ }>;
137
+ export type ImportSpecifier = Of<"ImportSpecifier", {
138
+ imported: Node;
139
+ local: Identifier;
140
+ importKind: "type" | "value";
141
+ }>;
142
+ export type ImportDefaultSpecifier = Of<"ImportDefaultSpecifier", {
143
+ local: Identifier;
144
+ }>;
145
+ export type ImportNamespaceSpecifier = Of<"ImportNamespaceSpecifier", {
146
+ local: Identifier;
147
+ }>;
148
+ export type ImportAttribute = Of<"ImportAttribute", {
149
+ key: Node;
150
+ value: StringLiteral;
151
+ }>;
152
+ export type ExportNamedDeclaration = Of<"ExportNamedDeclaration", {
153
+ declaration: Node | null;
154
+ specifiers: Node[];
155
+ source: StringLiteral | null;
156
+ attributes: Node[];
157
+ exportKind: "type" | "value";
158
+ }>;
159
+ export type ExportSpecifier = Of<"ExportSpecifier", {
160
+ local: Node;
161
+ exported: Node;
162
+ exportKind: "type" | "value";
163
+ }>;
164
+ export type ExportDefaultDeclaration = Of<"ExportDefaultDeclaration", {
165
+ declaration: Node;
166
+ }>;
167
+ export type ExportAllDeclaration = Of<"ExportAllDeclaration", {
168
+ exported: Node | null;
169
+ source: StringLiteral;
170
+ attributes: Node[];
171
+ exportKind: "type" | "value";
172
+ }>;
173
+ export type Identifier = Of<"Identifier", {
174
+ name: string;
175
+ optional?: boolean;
176
+ typeAnnotation?: Node | null;
177
+ }>;
178
+ export type PrivateName = Of<"PrivateName", {
179
+ name: string;
180
+ }>;
181
+ export type StringLiteral = Of<"StringLiteral", {
182
+ raw: string;
183
+ }>;
184
+ export type NumericLiteral = Of<"NumericLiteral", {
185
+ raw: string;
186
+ }>;
187
+ export type BooleanLiteral = Of<"BooleanLiteral", {
188
+ value: boolean;
189
+ }>;
190
+ export type NullLiteral = Of<"NullLiteral">;
191
+ export type RegExpLiteral = Of<"RegExpLiteral", {
192
+ raw: string;
193
+ }>;
194
+ export type TemplateLiteral = Of<"TemplateLiteral", {
195
+ quasis: TemplateElement[];
196
+ expressions: Node[];
197
+ }>;
198
+ export type TemplateElement = Of<"TemplateElement", {
199
+ raw: string;
200
+ tail: boolean;
201
+ }>;
202
+ export type TaggedTemplateExpression = Of<"TaggedTemplateExpression", {
203
+ tag: Node;
204
+ quasi: TemplateLiteral;
205
+ typeArguments: TypeArguments | null;
206
+ }>;
207
+ export type ThisExpression = Of<"ThisExpression">;
208
+ export type Super = Of<"Super">;
209
+ export type ArrayExpression = Of<"ArrayExpression", {
210
+ elements: (Node | null)[];
211
+ }>;
212
+ export type ObjectExpression = Of<"ObjectExpression", {
213
+ properties: Node[];
214
+ }>;
215
+ export type Property = Of<"Property", {
216
+ key: Node;
217
+ value: Node;
218
+ kind: "get" | "init" | "set";
219
+ method: boolean;
220
+ shorthand: boolean;
221
+ computed: boolean;
222
+ }>;
223
+ export type SpreadElement = Of<"SpreadElement", {
224
+ argument: Node;
225
+ }>;
226
+ export type FunctionExpression = Of<"FunctionExpression", FunctionParts>;
227
+ export type ArrowFunctionExpression = Of<"ArrowFunctionExpression", FunctionParts & {
228
+ body: Node;
229
+ }>;
230
+ export type ClassExpression = Of<"ClassExpression", ClassParts>;
231
+ export type CallExpression = Of<"CallExpression", {
232
+ callee: Node;
233
+ arguments: Node[];
234
+ optional: boolean;
235
+ typeArguments: TypeArguments | null;
236
+ }>;
237
+ export type NewExpression = Of<"NewExpression", {
238
+ callee: Node;
239
+ arguments: Node[];
240
+ typeArguments: TypeArguments | null;
241
+ parentheses: boolean;
242
+ }>;
243
+ export type ImportExpression = Of<"ImportExpression", {
244
+ source: Node;
245
+ options: Node | null;
246
+ phase: string | null;
247
+ }>;
248
+ export type MemberExpression = Of<"MemberExpression", {
249
+ object: Node;
250
+ property: Node;
251
+ computed: boolean;
252
+ optional: boolean;
253
+ }>;
254
+ export type MetaProperty = Of<"MetaProperty", {
255
+ meta: string;
256
+ property: string;
257
+ }>;
258
+ export type UnaryExpression = Of<"UnaryExpression", {
259
+ operator: string;
260
+ argument: Node;
261
+ }>;
262
+ export type UpdateExpression = Of<"UpdateExpression", {
263
+ operator: string;
264
+ prefix: boolean;
265
+ argument: Node;
266
+ }>;
267
+ export type BinaryExpression = Of<"BinaryExpression", {
268
+ operator: string;
269
+ left: Node;
270
+ right: Node;
271
+ }>;
272
+ export type LogicalExpression = Of<"LogicalExpression", {
273
+ operator: string;
274
+ left: Node;
275
+ right: Node;
276
+ }>;
277
+ export type AssignmentExpression = Of<"AssignmentExpression", {
278
+ operator: string;
279
+ left: Node;
280
+ right: Node;
281
+ }>;
282
+ export type ConditionalExpression = Of<"ConditionalExpression", {
283
+ test: Node;
284
+ consequent: Node;
285
+ alternate: Node;
286
+ }>;
287
+ export type SequenceExpression = Of<"SequenceExpression", {
288
+ expressions: Node[];
289
+ }>;
290
+ export type YieldExpression = Of<"YieldExpression", {
291
+ argument: Node | null;
292
+ delegate: boolean;
293
+ }>;
294
+ export type AwaitExpression = Of<"AwaitExpression", {
295
+ argument: Node;
296
+ }>;
297
+ export type ObjectPattern = Of<"ObjectPattern", {
298
+ properties: Node[];
299
+ typeAnnotation: Node | null;
300
+ optional?: boolean;
301
+ }>;
302
+ export type ArrayPattern = Of<"ArrayPattern", {
303
+ elements: (Node | null)[];
304
+ typeAnnotation: Node | null;
305
+ optional?: boolean;
306
+ }>;
307
+ export type AssignmentPattern = Of<"AssignmentPattern", {
308
+ left: Node;
309
+ right: Node;
310
+ }>;
311
+ export type RestElement = Of<"RestElement", {
312
+ argument: Node;
313
+ typeAnnotation: Node | null;
314
+ optional?: boolean;
315
+ }>;
316
+ export type ParameterProperty = Of<"TSParameterProperty", Modifiers & {
317
+ decorators: Decorator[];
318
+ parameter: Node;
319
+ }>;
320
+ interface ClassParts {
321
+ id: Identifier | null;
322
+ superClass: Node | null;
323
+ superTypeArguments: TypeArguments | null;
324
+ implements: Node[];
325
+ body: ClassBody;
326
+ decorators: Decorator[];
327
+ typeParameters: TypeParameters | null;
328
+ abstract: boolean;
329
+ declare: boolean;
330
+ }
331
+ export type ClassBody = Of<"ClassBody", {
332
+ body: Node[];
333
+ }>;
334
+ export type MethodDefinition = Of<"MethodDefinition", Modifiers & {
335
+ key: Node;
336
+ value: FunctionExpression;
337
+ kind: "constructor" | "get" | "method" | "set";
338
+ computed: boolean;
339
+ optional: boolean;
340
+ decorators: Decorator[];
341
+ }>;
342
+ export type PropertyDefinition = Of<"PropertyDefinition", Modifiers & {
343
+ key: Node;
344
+ value: Node | null;
345
+ computed: boolean;
346
+ optional: boolean;
347
+ definite: boolean;
348
+ accessor: boolean;
349
+ typeAnnotation: Node | null;
350
+ decorators: Decorator[];
351
+ }>;
352
+ export type StaticBlock = Of<"StaticBlock", {
353
+ body: Node[];
354
+ }>;
355
+ export type Decorator = Of<"Decorator", {
356
+ expression: Node;
357
+ }>;
358
+ export type JSXElement = Of<"JSXElement", {
359
+ name: string | null;
360
+ attributes: Node[];
361
+ children: Node[];
362
+ selfClosing: boolean;
363
+ typeArguments: TypeArguments | null;
364
+ }>;
365
+ export type JSXAttribute = Of<"JSXAttribute", {
366
+ name: string;
367
+ value: Node | null;
368
+ }>;
369
+ export type JSXSpreadAttribute = Of<"JSXSpreadAttribute", {
370
+ argument: Node;
371
+ }>;
372
+ export type JSXExpressionContainer = Of<"JSXExpressionContainer", {
373
+ expression: Node | null;
374
+ }>;
375
+ export type JSXSpreadChild = Of<"JSXSpreadChild", {
376
+ expression: Node;
377
+ }>;
378
+ export type JSXText = Of<"JSXText", {
379
+ raw: string;
380
+ }>;
381
+ export type TSAsExpression = Of<"TSAsExpression", {
382
+ expression: Node;
383
+ typeAnnotation: Node;
384
+ }>;
385
+ export type TSSatisfiesExpression = Of<"TSSatisfiesExpression", {
386
+ expression: Node;
387
+ typeAnnotation: Node;
388
+ }>;
389
+ export type TSNonNullExpression = Of<"TSNonNullExpression", {
390
+ expression: Node;
391
+ }>;
392
+ export type TSTypeAssertion = Of<"TSTypeAssertion", {
393
+ expression: Node;
394
+ typeAnnotation: Node;
395
+ }>;
396
+ export type TSInstantiationExpression = Of<"TSInstantiationExpression", {
397
+ expression: Node;
398
+ typeArguments: TypeArguments;
399
+ }>;
400
+ export type TSInterfaceDeclaration = Of<"TSInterfaceDeclaration", {
401
+ id: Identifier;
402
+ typeParameters: TypeParameters | null;
403
+ extends: Node[];
404
+ body: TSInterfaceBody;
405
+ declare: boolean;
406
+ }>;
407
+ export type TSInterfaceBody = Of<"TSInterfaceBody", {
408
+ body: Node[];
409
+ }>;
410
+ export type TSTypeAliasDeclaration = Of<"TSTypeAliasDeclaration", {
411
+ id: Identifier;
412
+ typeParameters: TypeParameters | null;
413
+ typeAnnotation: Node;
414
+ declare: boolean;
415
+ }>;
416
+ export type TSEnumDeclaration = Of<"TSEnumDeclaration", {
417
+ id: Identifier;
418
+ members: TSEnumMember[];
419
+ const: boolean;
420
+ declare: boolean;
421
+ }>;
422
+ export type TSEnumMember = Of<"TSEnumMember", {
423
+ id: Node;
424
+ initializer: Node | null;
425
+ }>;
426
+ export type TSModuleDeclaration = Of<"TSModuleDeclaration", {
427
+ id: Node;
428
+ body: TSModuleBlock | null;
429
+ kind: "global" | "module" | "namespace";
430
+ declare: boolean;
431
+ }>;
432
+ export type TSModuleBlock = Of<"TSModuleBlock", {
433
+ body: Node[];
434
+ }>;
435
+ export type TSDeclareFunction = Of<"TSDeclareFunction", FunctionParts & {
436
+ declare: boolean;
437
+ }>;
438
+ export type TSExportAssignment = Of<"TSExportAssignment", {
439
+ expression: Node;
440
+ }>;
441
+ export type TSNamespaceExportDeclaration = Of<"TSNamespaceExportDeclaration", {
442
+ id: Identifier;
443
+ }>;
444
+ export type TSImportEqualsDeclaration = Of<"TSImportEqualsDeclaration", {
445
+ id: Identifier;
446
+ moduleReference: Node;
447
+ importKind: "type" | "value";
448
+ isExport: boolean;
449
+ }>;
450
+ export type TSExternalModuleReference = Of<"TSExternalModuleReference", {
451
+ expression: StringLiteral;
452
+ }>;
453
+ export type TypeParameters = Of<"TSTypeParameterDeclaration", {
454
+ params: TSTypeParameter[];
455
+ }>;
456
+ export type TSTypeParameter = Of<"TSTypeParameter", {
457
+ name: string;
458
+ constraint: Node | null;
459
+ default: Node | null;
460
+ in: boolean;
461
+ out: boolean;
462
+ const: boolean;
463
+ }>;
464
+ export type TypeArguments = Of<"TSTypeParameterInstantiation", {
465
+ params: Node[];
466
+ }>;
467
+ export type TSKeyword = Of<"TSKeyword", {
468
+ name: string;
469
+ }>;
470
+ export type TSTypeReference = Of<"TSTypeReference", {
471
+ typeName: Node;
472
+ typeArguments: TypeArguments | null;
473
+ }>;
474
+ export type TSQualifiedName = Of<"TSQualifiedName", {
475
+ left: Node;
476
+ right: Identifier;
477
+ }>;
478
+ export type TSLiteralType = Of<"TSLiteralType", {
479
+ literal: Node;
480
+ }>;
481
+ export type TSTemplateLiteralType = Of<"TSTemplateLiteralType", {
482
+ quasis: TemplateElement[];
483
+ types: Node[];
484
+ }>;
485
+ export type TSUnionType = Of<"TSUnionType", {
486
+ types: Node[];
487
+ }>;
488
+ export type TSIntersectionType = Of<"TSIntersectionType", {
489
+ types: Node[];
490
+ }>;
491
+ export type TSFunctionType = Of<"TSFunctionType", {
492
+ typeParameters: TypeParameters | null;
493
+ params: Node[];
494
+ returnType: Node;
495
+ }>;
496
+ export type TSConstructorType = Of<"TSConstructorType", {
497
+ typeParameters: TypeParameters | null;
498
+ params: Node[];
499
+ returnType: Node;
500
+ abstract: boolean;
501
+ }>;
502
+ export type TSArrayType = Of<"TSArrayType", {
503
+ elementType: Node;
504
+ }>;
505
+ export type TSTupleType = Of<"TSTupleType", {
506
+ elementTypes: Node[];
507
+ }>;
508
+ export type TSNamedTupleMember = Of<"TSNamedTupleMember", {
509
+ label: Identifier;
510
+ elementType: Node;
511
+ optional: boolean;
512
+ }>;
513
+ export type TSOptionalType = Of<"TSOptionalType", {
514
+ typeAnnotation: Node;
515
+ }>;
516
+ export type TSRestType = Of<"TSRestType", {
517
+ typeAnnotation: Node;
518
+ }>;
519
+ export type TSTypeLiteral = Of<"TSTypeLiteral", {
520
+ members: Node[];
521
+ }>;
522
+ export type TSTypeOperator = Of<"TSTypeOperator", {
523
+ operator: string;
524
+ typeAnnotation: Node;
525
+ }>;
526
+ export type TSIndexedAccessType = Of<"TSIndexedAccessType", {
527
+ objectType: Node;
528
+ indexType: Node;
529
+ }>;
530
+ export type TSConditionalType = Of<"TSConditionalType", {
531
+ checkType: Node;
532
+ extendsType: Node;
533
+ trueType: Node;
534
+ falseType: Node;
535
+ }>;
536
+ export type TSInferType = Of<"TSInferType", {
537
+ name: string;
538
+ constraint: Node | null;
539
+ }>;
540
+ export type TSTypeQuery = Of<"TSTypeQuery", {
541
+ exprName: Node;
542
+ typeArguments: TypeArguments | null;
543
+ }>;
544
+ export type TSImportType = Of<"TSImportType", {
545
+ argument: Node;
546
+ options: Node | null;
547
+ qualifier: Node | null;
548
+ typeArguments: TypeArguments | null;
549
+ }>;
550
+ export type TSMappedType = Of<"TSMappedType", {
551
+ key: string;
552
+ constraint: Node;
553
+ nameType: Node | null;
554
+ typeAnnotation: Node | null;
555
+ optional: string | null;
556
+ readonly: string | null;
557
+ }>;
558
+ export type TSTypePredicate = Of<"TSTypePredicate", {
559
+ parameterName: Node;
560
+ typeAnnotation: Node | null;
561
+ asserts: boolean;
562
+ }>;
563
+ export type TSThisType = Of<"TSThisType">;
564
+ export type TSParenthesizedType = Of<"TSParenthesizedType", {
565
+ typeAnnotation: Node;
566
+ }>;
567
+ export type TSPropertySignature = Of<"TSPropertySignature", {
568
+ key: Node;
569
+ computed: boolean;
570
+ optional: boolean;
571
+ readonly: boolean;
572
+ typeAnnotation: Node | null;
573
+ }>;
574
+ export type TSMethodSignature = Of<"TSMethodSignature", {
575
+ key: Node;
576
+ computed: boolean;
577
+ optional: boolean;
578
+ kind: "get" | "method" | "set";
579
+ typeParameters: TypeParameters | null;
580
+ params: Node[];
581
+ returnType: Node | null;
582
+ }>;
583
+ export type TSIndexSignature = Of<"TSIndexSignature", {
584
+ parameters: Node[];
585
+ typeAnnotation: Node | null;
586
+ readonly: boolean;
587
+ static: boolean;
588
+ }>;
589
+ export type TSCallSignatureDeclaration = Of<"TSCallSignatureDeclaration", {
590
+ typeParameters: TypeParameters | null;
591
+ params: Node[];
592
+ returnType: Node | null;
593
+ }>;
594
+ export type TSConstructSignatureDeclaration = Of<"TSConstructSignatureDeclaration", {
595
+ typeParameters: TypeParameters | null;
596
+ params: Node[];
597
+ returnType: Node | null;
598
+ }>;
599
+ export type Node = ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BooleanLiteral | BreakStatement | CallExpression | CatchClause | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | Directive | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportAttribute | ImportDeclaration | ImportDefaultSpecifier | ImportExpression | ImportNamespaceSpecifier | ImportSpecifier | JSXAttribute | JSXElement | JSXExpressionContainer | JSXSpreadAttribute | JSXSpreadChild | JSXText | LabeledStatement | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | NullLiteral | NumericLiteral | ObjectExpression | ObjectPattern | ParameterProperty | PrivateName | Program | Property | PropertyDefinition | RegExpLiteral | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | StringLiteral | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | TSArrayType | TSAsExpression | TSCallSignatureDeclaration | TSConditionalType | TSConstructorType | TSConstructSignatureDeclaration | TSDeclareFunction | TSEnumDeclaration | TSEnumMember | TSExportAssignment | TSExternalModuleReference | TSFunctionType | TSImportEqualsDeclaration | TSImportType | TSIndexedAccessType | TSIndexSignature | TSInferType | TSInstantiationExpression | TSInterfaceBody | TSInterfaceDeclaration | TSIntersectionType | TSKeyword | TSLiteralType | TSMappedType | TSMethodSignature | TSModuleBlock | TSModuleDeclaration | TSNamedTupleMember | TSNamespaceExportDeclaration | TSNonNullExpression | TSOptionalType | TSParenthesizedType | TSPropertySignature | TSQualifiedName | TSRestType | TSSatisfiesExpression | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeAliasDeclaration | TSTypeAssertion | TSTypeLiteral | TSTypeOperator | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TypeArguments | TypeParameters | TSTypeParameter | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
600
+ export type NodeType = Node["type"];
601
+ export type NodeOf<T extends NodeType> = Extract<Node, {
602
+ type: T;
603
+ }>;
604
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { Program } from "./ast.js";
2
+ import type { Root } from "./markdown/ast.js";
3
+ import { type MarkdownOptions } from "./markdown/blocks.js";
4
+ import type { Options } from "./parser/base.js";
5
+ import type { Comment } from "./scanner.js";
6
+ export type * from "./ast.js";
7
+ export { default as Lines } from "./lines.js";
8
+ export type * as Markdown from "./markdown/ast.js";
9
+ export type { Comment, Token } from "./scanner.js";
10
+ export { ParseError } from "./scanner.js";
11
+ export { default as Walker } from "./walker.js";
12
+ export type { MarkdownOptions, Options };
13
+ export interface Parsed {
14
+ program: Program;
15
+ comments: Comment[];
16
+ }
17
+ /** How a file is parsed, decided by its extension. */
18
+ export interface Language {
19
+ json: boolean;
20
+ typescript: boolean;
21
+ jsx: boolean;
22
+ }
23
+ /** The language of a JavaScript, TypeScript, JSX or JSON file, undefined for others. */
24
+ export declare function language(file: string): Language | undefined;
25
+ /** Whether a file is Markdown, by its extension. */
26
+ export declare function isMarkdown(file: string): boolean;
27
+ /** Parses CommonMark, with GitHub's tables, task lists and strikethrough unless `gfm` is false. */
28
+ export declare function parseMarkdown(source: string, options?: MarkdownOptions): Root;
29
+ export declare function parse(source: string, options: Options): Parsed;
30
+ /** Parses a single expression, like a JSON document, as an expression statement program. */
31
+ export declare function parseExpression(source: string): Parsed;
@@ -0,0 +1,7 @@
1
+ /** Converts offsets to 1-based lines and columns. */
2
+ export default class Lines {
3
+ #private;
4
+ constructor(text: string);
5
+ line(offset: number): number;
6
+ column(offset: number): number;
7
+ }