@cjser/jsdoc-type-pratt-parser 9.1.1-cjser.2

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,733 @@
1
+ import { Node } from "estree";
2
+ //#region src/result/NonRootResult.d.ts
3
+ /**
4
+ * A parse sub result that might not be a valid type expression on its own.
5
+ */
6
+ type NonRootResult = RootResult | PropertyResult | ObjectFieldResult | JsdocObjectFieldResult | KeyValueResult | MappedTypeResult | IndexSignatureResult | TypeParameterResult | CallSignatureResult | ConstructorSignatureResult | MethodSignatureResult | IndexedAccessIndexResult | ComputedPropertyResult | ComputedMethodResult;
7
+ interface ObjectFieldResult extends BaseNode {
8
+ type: 'JsdocTypeObjectField';
9
+ key: string | MappedTypeResult | IndexSignatureResult | ComputedPropertyResult | ComputedMethodResult;
10
+ right: RootResult | undefined;
11
+ optional: boolean;
12
+ readonly: boolean;
13
+ meta: {
14
+ quote: QuoteStyle | undefined;
15
+ postColonSpacing?: string;
16
+ postKeySpacing?: string;
17
+ postOptionalSpacing?: string;
18
+ };
19
+ }
20
+ interface JsdocObjectFieldResult extends BaseNode {
21
+ type: 'JsdocTypeJsdocObjectField';
22
+ left: RootResult;
23
+ right: RootResult;
24
+ }
25
+ interface PropertyResult extends BaseNode {
26
+ type: 'JsdocTypeProperty';
27
+ value: string;
28
+ meta: {
29
+ quote: QuoteStyle | undefined;
30
+ };
31
+ }
32
+ /**
33
+ * A key value pair represented by a `:`. Can occur as a named parameter of a {@link FunctionResult} or as an entry for
34
+ * an {@link TupleResult}. Is a {@link NonRootResult}.
35
+ */
36
+ interface KeyValueResult extends BaseNode {
37
+ type: 'JsdocTypeKeyValue';
38
+ key: string;
39
+ right: RootResult | undefined;
40
+ optional: boolean;
41
+ variadic: boolean;
42
+ meta?: {
43
+ postKeySpacing: string;
44
+ postOptionalSpacing: string;
45
+ postVariadicSpacing: string;
46
+ postColonSpacing: string;
47
+ };
48
+ }
49
+ interface IndexSignatureResult extends BaseNode {
50
+ type: 'JsdocTypeIndexSignature';
51
+ key: string;
52
+ right: RootResult;
53
+ }
54
+ interface MappedTypeResult extends BaseNode {
55
+ type: 'JsdocTypeMappedType';
56
+ key: string;
57
+ right: RootResult;
58
+ }
59
+ interface TypeParameterResult extends BaseNode {
60
+ type: 'JsdocTypeTypeParameter';
61
+ defaultValue?: RootResult;
62
+ name: NameResult;
63
+ constraint?: RootResult;
64
+ meta?: {
65
+ defaultValueSpacing: string;
66
+ };
67
+ }
68
+ interface CallSignatureResult extends BaseNode {
69
+ type: 'JsdocTypeCallSignature';
70
+ parameters: Array<RootResult | KeyValueResult>;
71
+ returnType: RootResult;
72
+ typeParameters?: TypeParameterResult[];
73
+ meta?: {
74
+ parameterSpacing: string;
75
+ typeParameterSpacing: string;
76
+ postGenericSpacing: string;
77
+ preReturnMarkerSpacing?: string;
78
+ postReturnMarkerSpacing?: string;
79
+ };
80
+ }
81
+ interface ConstructorSignatureResult extends BaseNode {
82
+ type: 'JsdocTypeConstructorSignature';
83
+ parameters: Array<RootResult | KeyValueResult>;
84
+ returnType: RootResult;
85
+ typeParameters?: TypeParameterResult[];
86
+ meta?: {
87
+ parameterSpacing: string;
88
+ typeParameterSpacing: string;
89
+ postNewSpacing: string;
90
+ postGenericSpacing: string;
91
+ preReturnMarkerSpacing?: string;
92
+ postReturnMarkerSpacing?: string;
93
+ };
94
+ }
95
+ interface MethodSignatureResult extends BaseNode {
96
+ type: 'JsdocTypeMethodSignature';
97
+ name: string;
98
+ meta: {
99
+ quote: QuoteStyle | undefined;
100
+ parameterSpacing?: string;
101
+ typeParameterSpacing?: string;
102
+ postMethodNameSpacing?: string;
103
+ postGenericSpacing?: string;
104
+ preReturnMarkerSpacing?: string;
105
+ postReturnMarkerSpacing?: string;
106
+ };
107
+ parameters: Array<RootResult | KeyValueResult>;
108
+ returnType: RootResult;
109
+ typeParameters?: TypeParameterResult[];
110
+ }
111
+ interface IndexedAccessIndexResult extends BaseNode {
112
+ type: 'JsdocTypeIndexedAccessIndex';
113
+ right: RootResult;
114
+ }
115
+ interface ComputedPropertyResult extends BaseNode {
116
+ type: 'JsdocTypeComputedProperty';
117
+ value: RootResult | Node;
118
+ }
119
+ interface ComputedMethodResult extends BaseNode {
120
+ type: 'JsdocTypeComputedMethod';
121
+ value: RootResult | Node;
122
+ optional: boolean;
123
+ parameters: Array<RootResult | KeyValueResult>;
124
+ returnType: RootResult;
125
+ typeParameters?: TypeParameterResult[];
126
+ meta?: {
127
+ parameterSpacing: string;
128
+ typeParameterSpacing: string;
129
+ postGenericSpacing: string;
130
+ preReturnMarkerSpacing?: string;
131
+ postReturnMarkerSpacing?: string;
132
+ };
133
+ }
134
+ //#endregion
135
+ //#region src/result/RootResult.d.ts
136
+ interface Location {
137
+ loc?: {
138
+ end: {
139
+ column: number;
140
+ line: number;
141
+ };
142
+ start: {
143
+ column: number;
144
+ line: number;
145
+ };
146
+ };
147
+ }
148
+ interface Range {
149
+ range?: [number, number];
150
+ }
151
+ interface BaseNode extends Range, Location {}
152
+ /**
153
+ * A parse result that corresponds to a valid type expression.
154
+ */
155
+ type RootResult = NameResult | InferResult | UniqueSymbolResult | UnionResult | GenericResult | StringValueResult | NullResult | UndefinedResult | AnyResult | UnknownResult | FunctionResult | ObjectResult | NamePathResult | SymbolResult | TypeOfResult | KeyOfResult | ImportResult | TupleResult | SpecialNamePath | OptionalResult<RootResult> | NullableResult<RootResult> | NotNullableResult<RootResult> | VariadicResult<RootResult> | ParenthesisResult | IntersectionResult | NumberResult | BigIntResult | PredicateResult | AssertsResult | ReadonlyArrayResult | AssertsPlainResult | ConditionalResult | TemplateLiteralResult;
156
+ type QuoteStyle = 'single' | 'double';
157
+ /**
158
+ * `element` is optional.
159
+ */
160
+ interface OptionalResult<T extends RootResult> extends BaseNode {
161
+ type: 'JsdocTypeOptional';
162
+ element: T;
163
+ meta: {
164
+ position: 'prefix' | 'suffix';
165
+ };
166
+ }
167
+ /**
168
+ * A nullable type.
169
+ */
170
+ interface NullableResult<T extends RootResult> extends BaseNode {
171
+ type: 'JsdocTypeNullable';
172
+ element: T;
173
+ meta: {
174
+ position: 'prefix' | 'suffix';
175
+ };
176
+ }
177
+ /**
178
+ * A not nullable type.
179
+ */
180
+ interface NotNullableResult<T extends RootResult> extends BaseNode {
181
+ type: 'JsdocTypeNotNullable';
182
+ element: T;
183
+ meta: {
184
+ position: 'prefix' | 'suffix';
185
+ };
186
+ }
187
+ /**
188
+ * A rest or spread parameter. It can either occur in `@param` tags or as last parameter of a function,
189
+ * or it is a spread tuple or object type and can occur inside these. For any mode that is not `jsdoc` this can
190
+ * only occur in position `'suffix'`.
191
+ */
192
+ interface VariadicResult<T extends RootResult> extends BaseNode {
193
+ type: 'JsdocTypeVariadic';
194
+ element?: T;
195
+ meta: {
196
+ position: 'prefix' | 'suffix' | undefined;
197
+ squareBrackets: boolean;
198
+ };
199
+ }
200
+ /**
201
+ * A type name.
202
+ */
203
+ interface NameResult extends BaseNode {
204
+ type: 'JsdocTypeName';
205
+ value: string;
206
+ }
207
+ /**
208
+ * A TypeScript `infer` type parameter within a generic argument list.
209
+ * Represents the `infer X` construct when it appears as a generic argument
210
+ * (e.g. `Map<any, infer V>`) or alongside other parameters.
211
+ */
212
+ interface InferResult extends BaseNode {
213
+ type: 'JsdocTypeInfer';
214
+ element: NameResult;
215
+ }
216
+ /**
217
+ * The TypeScript `unique symbol` type.
218
+ */
219
+ interface UniqueSymbolResult extends BaseNode {
220
+ type: 'JsdocTypeUniqueSymbol';
221
+ }
222
+ /**
223
+ * A type union.
224
+ */
225
+ interface UnionResult extends BaseNode {
226
+ type: 'JsdocTypeUnion';
227
+ elements: RootResult[];
228
+ meta?: {
229
+ spacing: string;
230
+ };
231
+ }
232
+ /**
233
+ * A generic type. The property `left` is the generic type that has `elements` as type values for its type parameters.
234
+ * Array types that are written as `Type[]` always have the name `Array` as the `left` type and `elements` will contain
235
+ * only one element (in this case the name `Type`). To differentiate `Type[]` and `Array<Type>` there is the meta
236
+ * property
237
+ * `brackets`.
238
+ */
239
+ interface GenericResult extends BaseNode {
240
+ type: 'JsdocTypeGeneric';
241
+ left: RootResult;
242
+ elements: RootResult[];
243
+ meta: {
244
+ brackets: 'angle' | 'square';
245
+ dot: boolean;
246
+ elementSpacing?: string;
247
+ };
248
+ }
249
+ /**
250
+ * A string value as a type.
251
+ */
252
+ interface StringValueResult extends BaseNode {
253
+ type: 'JsdocTypeStringValue';
254
+ value: string;
255
+ meta: {
256
+ quote: QuoteStyle;
257
+ };
258
+ }
259
+ /**
260
+ * The `null` type.
261
+ */
262
+ interface NullResult extends BaseNode {
263
+ type: 'JsdocTypeNull';
264
+ }
265
+ /**
266
+ * The `undefined` type.
267
+ */
268
+ interface UndefinedResult extends BaseNode {
269
+ type: 'JsdocTypeUndefined';
270
+ }
271
+ /**
272
+ * The `any` type, represented by `*` (`any` is parsed as a name).
273
+ */
274
+ interface AnyResult extends BaseNode {
275
+ type: 'JsdocTypeAny';
276
+ }
277
+ /**
278
+ * The unknown type, represented by `?` (`unknown` is parsed as a name).
279
+ */
280
+ interface UnknownResult extends BaseNode {
281
+ type: 'JsdocTypeUnknown';
282
+ }
283
+ /**
284
+ * A function type. Has `parameters` which can be named, if the grammar supports it. Some grammars only allow named
285
+ * `this` and `new` parameters. Named parameters are returned as {@link KeyValueResult}s. It can have a `returnType`.
286
+ * It can be a normal function type or an arrow, which is indicated by `arrow`. If `parenthesis` is false, it is any
287
+ * kind of function without specified parameters or return type.
288
+ */
289
+ interface FunctionResult extends BaseNode {
290
+ type: 'JsdocTypeFunction';
291
+ parameters: Array<RootResult | KeyValueResult>;
292
+ returnType?: RootResult;
293
+ constructor: boolean;
294
+ arrow: boolean;
295
+ parenthesis: boolean;
296
+ typeParameters?: TypeParameterResult[];
297
+ meta?: {
298
+ parameterSpacing: string;
299
+ typeParameterSpacing: string;
300
+ preReturnMarkerSpacing: string;
301
+ postReturnMarkerSpacing: string;
302
+ postGenericSpacing?: string;
303
+ };
304
+ }
305
+ /**
306
+ * An object type. Contains entries which can be {@link KeyValueResult}s or {@link NameResult}s. In most grammars the
307
+ * keys need to be {@link NameResult}s. In some grammars it possible that an entry is only a {@link RootResult} or a
308
+ * {@link NumberResult} without a key. The separator is `'comma'` by default.
309
+ */
310
+ interface ObjectResult extends BaseNode {
311
+ type: 'JsdocTypeObject';
312
+ elements: Array<ObjectFieldResult | JsdocObjectFieldResult | CallSignatureResult | ConstructorSignatureResult | MethodSignatureResult | ComputedPropertyResult | ComputedMethodResult>;
313
+ meta: {
314
+ bracketSpacing?: string;
315
+ separator: 'comma' | 'semicolon' | 'linebreak' | 'comma-and-linebreak' | 'semicolon-and-linebreak' | undefined;
316
+ separatorForSingleObjectField?: boolean;
317
+ trailingPunctuation?: boolean;
318
+ propertyIndent?: string;
319
+ };
320
+ }
321
+ type SpecialNamePathType = 'module' | 'event' | 'external';
322
+ /**
323
+ * A module type. Often this is a `left` type of {@link NamePathResult}.
324
+ */
325
+ interface SpecialNamePath<Type extends SpecialNamePathType = SpecialNamePathType> extends BaseNode {
326
+ type: 'JsdocTypeSpecialNamePath';
327
+ value: string;
328
+ specialType: Type;
329
+ meta: {
330
+ quote: QuoteStyle | undefined;
331
+ };
332
+ }
333
+ /**
334
+ * A name path type. This can be a property path separated by `.` or an inner or static member (`~`, `#`).
335
+ */
336
+ interface NamePathResult extends BaseNode {
337
+ type: 'JsdocTypeNamePath';
338
+ left: RootResult;
339
+ right: PropertyResult | SpecialNamePath<'event'> | IndexedAccessIndexResult;
340
+ pathType: 'inner' | 'instance' | 'property' | 'property-brackets';
341
+ }
342
+ /**
343
+ * A symbol type. Only available in `jsdoc` mode.
344
+ */
345
+ interface SymbolResult extends BaseNode {
346
+ type: 'JsdocTypeSymbol';
347
+ value: string;
348
+ element?: NumberResult | NameResult | VariadicResult<NameResult>;
349
+ }
350
+ /**
351
+ * A typeof type. The `element` normally should be a name.
352
+ */
353
+ interface TypeOfResult extends BaseNode {
354
+ type: 'JsdocTypeTypeof';
355
+ element: RootResult;
356
+ }
357
+ /**
358
+ * A keyof type. The `element` normally should be a name.
359
+ */
360
+ interface KeyOfResult extends BaseNode {
361
+ type: 'JsdocTypeKeyof';
362
+ element: RootResult;
363
+ }
364
+ /**
365
+ * An import type. The `element` is {@link StringValueResult} representing the path. Often the `left` side of an
366
+ * {@link NamePathResult}.
367
+ */
368
+ interface ImportResult extends BaseNode {
369
+ type: 'JsdocTypeImport';
370
+ element: StringValueResult;
371
+ }
372
+ /**
373
+ * A tuple type containing multiple `elements`.
374
+ */
375
+ interface TupleResult extends BaseNode {
376
+ type: 'JsdocTypeTuple';
377
+ elements: RootResult[] | KeyValueResult[];
378
+ meta?: {
379
+ elementSpacing: string;
380
+ };
381
+ }
382
+ /**
383
+ * A type enclosed in parenthesis. Often {@link UnionResult}s ot {@link IntersectionResult}s.
384
+ */
385
+ interface ParenthesisResult extends BaseNode {
386
+ type: 'JsdocTypeParenthesis';
387
+ element: RootResult;
388
+ }
389
+ /**
390
+ * An intersection type.
391
+ */
392
+ interface IntersectionResult extends BaseNode {
393
+ type: 'JsdocTypeIntersection';
394
+ elements: RootResult[];
395
+ }
396
+ /**
397
+ * A number. Can be the key of an {@link ObjectResult} entry or the parameter of a {@link SymbolResult}.
398
+ * Is a {@link NonRootResult}.
399
+ */
400
+ interface NumberResult extends BaseNode {
401
+ type: 'JsdocTypeNumber';
402
+ value: number;
403
+ }
404
+ /**
405
+ * A bigint literal.
406
+ * Is a {@link NonRootResult}.
407
+ */
408
+ interface BigIntResult extends BaseNode {
409
+ type: 'JsdocTypeBigInt';
410
+ value: string;
411
+ }
412
+ /**
413
+ * A typescript predicate. Is used in return annotations like this: `@return {x is string}`.
414
+ */
415
+ interface PredicateResult extends BaseNode {
416
+ type: 'JsdocTypePredicate';
417
+ left: NameResult;
418
+ right: RootResult;
419
+ }
420
+ /**
421
+ * An asserts result. Is used like this: `@return {asserts foo is Bar}`
422
+ */
423
+ interface AssertsResult extends BaseNode {
424
+ type: 'JsdocTypeAsserts';
425
+ left: NameResult;
426
+ right: RootResult;
427
+ }
428
+ /**
429
+ * A TypeScript readonly modifier. Is used like this: `readonly string[]`.
430
+ */
431
+ interface ReadonlyArrayResult extends BaseNode {
432
+ type: 'JsdocTypeReadonlyArray';
433
+ element: RootResult;
434
+ }
435
+ /**
436
+ * An asserts result without `is`. Is used like this: `@return {asserts foo}`
437
+ */
438
+ interface AssertsPlainResult extends BaseNode {
439
+ type: 'JsdocTypeAssertsPlain';
440
+ element: NameResult;
441
+ }
442
+ /**
443
+ * A TypeScript conditional. Is used like this: `A extends B ? C : D`.
444
+ */
445
+ interface ConditionalResult extends BaseNode {
446
+ type: 'JsdocTypeConditional';
447
+ checksType: RootResult;
448
+ extendsType: RootResult;
449
+ trueType: RootResult;
450
+ falseType: RootResult;
451
+ }
452
+ /**
453
+ * A TypeScript template literal. Is used like: `\`someText${someType}\``
454
+ */
455
+ interface TemplateLiteralResult extends BaseNode {
456
+ type: 'JsdocTypeTemplateLiteral';
457
+ literals: string[];
458
+ interpolations: RootResult[];
459
+ }
460
+ //#endregion
461
+ //#region src/parse.d.ts
462
+ type ParseMode = 'closure' | 'jsdoc' | 'typescript';
463
+ /**
464
+ * This function parses the given expression in the given mode and produces a {@link RootResult}.
465
+ * @param expression
466
+ * @param mode
467
+ */
468
+ declare function parse(expression: string, mode: ParseMode, { range, rangeStart, loc, locStart, module, strictMode, asyncFunctionBody, classContext, computedPropertyParser }?: {
469
+ range?: boolean;
470
+ rangeStart?: number;
471
+ loc?: boolean;
472
+ locStart?: {
473
+ column: number;
474
+ line: number;
475
+ };
476
+ module?: boolean;
477
+ strictMode?: boolean;
478
+ asyncFunctionBody?: boolean;
479
+ classContext?: boolean;
480
+ computedPropertyParser?: (text: string, options?: any) => unknown;
481
+ }): RootResult;
482
+ /**
483
+ * This function tries to parse the given expression in multiple modes and returns the first successful
484
+ * {@link RootResult}. By default it tries `'typescript'`, `'closure'` and `'jsdoc'` in this order. If
485
+ * no mode was successful it throws the error that was produced by the last parsing attempt.
486
+ * @param expression
487
+ * @param modes
488
+ */
489
+ declare function tryParse(expression: string, modes?: ParseMode[], { module, strictMode, asyncFunctionBody, classContext, range, rangeStart, loc, locStart }?: {
490
+ module?: boolean;
491
+ strictMode?: boolean;
492
+ asyncFunctionBody?: boolean;
493
+ classContext?: boolean;
494
+ range?: boolean;
495
+ rangeStart?: number;
496
+ loc?: boolean;
497
+ locStart?: {
498
+ column: number;
499
+ line: number;
500
+ };
501
+ }): RootResult;
502
+ /**
503
+ * This function parses the given expression in the given mode and produces a name path.
504
+ * @param expression
505
+ * @param mode
506
+ */
507
+ declare function parseNamePath(expression: string, mode: ParseMode, { includeSpecial }?: {
508
+ includeSpecial?: boolean;
509
+ }): RootResult;
510
+ /**
511
+ * This function parses the given expression in the given mode and produces a name.
512
+ * @param expression
513
+ * @param mode
514
+ */
515
+ declare function parseName(expression: string, mode: ParseMode): RootResult;
516
+ //#endregion
517
+ //#region src/transforms/transform.d.ts
518
+ type TransformFunction<TransformResult> = (parseResult: NonRootResult) => TransformResult;
519
+ type TransformRule<TransformResult, InputType extends NonRootResult> = (parseResult: InputType, transform: TransformFunction<TransformResult>) => TransformResult;
520
+ type TransformRules<TransformResult> = { [P in NonRootResult as P['type']]: TransformRule<TransformResult, P>; };
521
+ declare function transform<TransformResult>(rules: TransformRules<TransformResult>, parseResult: NonRootResult): TransformResult;
522
+ //#endregion
523
+ //#region src/transforms/catharsisTransform.d.ts
524
+ interface ModifiableResult {
525
+ optional?: boolean;
526
+ nullable?: boolean;
527
+ repeatable?: boolean;
528
+ }
529
+ type CatharsisParseResult = CatharsisNameResult | CatharsisUnionResult | CatharsisGenericResult | CatharsisNullResult | CatharsisUndefinedResult | CatharsisAllResult | CatharsisUnknownResult | CatharsisFunctionResult | CatharsisRecordResult | CatharsisFieldResult;
530
+ type CatharsisNameResult = ModifiableResult & {
531
+ type: 'NameExpression';
532
+ name: string;
533
+ reservedWord?: boolean;
534
+ };
535
+ type CatharsisUnionResult = ModifiableResult & {
536
+ type: 'TypeUnion';
537
+ elements: CatharsisParseResult[];
538
+ };
539
+ type CatharsisGenericResult = ModifiableResult & {
540
+ type: 'TypeApplication';
541
+ expression: CatharsisParseResult;
542
+ applications: CatharsisParseResult[];
543
+ };
544
+ type CatharsisNullResult = ModifiableResult & {
545
+ type: 'NullLiteral';
546
+ };
547
+ type CatharsisUndefinedResult = ModifiableResult & {
548
+ type: 'UndefinedLiteral';
549
+ };
550
+ type CatharsisAllResult = ModifiableResult & {
551
+ type: 'AllLiteral';
552
+ };
553
+ type CatharsisUnknownResult = ModifiableResult & {
554
+ type: 'UnknownLiteral';
555
+ };
556
+ type CatharsisFunctionResult = ModifiableResult & {
557
+ type: 'FunctionType';
558
+ params: CatharsisParseResult[];
559
+ result?: CatharsisParseResult;
560
+ this?: CatharsisParseResult;
561
+ new?: CatharsisParseResult;
562
+ };
563
+ type CatharsisFieldResult = ModifiableResult & {
564
+ type: 'FieldType';
565
+ key: CatharsisParseResult;
566
+ value: CatharsisParseResult | undefined;
567
+ };
568
+ type CatharsisRecordResult = ModifiableResult & {
569
+ type: 'RecordType';
570
+ fields: CatharsisFieldResult[];
571
+ };
572
+ declare function catharsisTransform(result: RootResult): CatharsisParseResult;
573
+ //#endregion
574
+ //#region src/transforms/jtpTransform.d.ts
575
+ type JtpResult = JtpNameResult | JtpNullableResult | JtpNotNullableResult | JtpOptionalResult | JtpVariadicResult | JtpTypeOfResult | JtpTupleResult | JtpKeyOfResult | JtpStringValueResult | JtpImportResult | JtpAnyResult | JtpUnknownResult | JtpFunctionResult | JtpGenericResult | JtpRecordEntryResult | JtpRecordResult | JtpMemberResult | JtpUnionResult | JtpParenthesisResult | JtpNamedParameterResult | JtpModuleResult | JtpFilePath | JtpIntersectionResult | JtpNumberResult;
576
+ type JtpQuoteStyle = 'single' | 'double' | 'none';
577
+ interface JtpNullableResult {
578
+ type: 'NULLABLE';
579
+ value: JtpResult;
580
+ meta: {
581
+ syntax: 'PREFIX_QUESTION_MARK' | 'SUFFIX_QUESTION_MARK';
582
+ };
583
+ }
584
+ interface JtpNotNullableResult {
585
+ type: 'NOT_NULLABLE';
586
+ value: JtpResult;
587
+ meta: {
588
+ syntax: 'PREFIX_BANG' | 'SUFFIX_BANG';
589
+ };
590
+ }
591
+ interface JtpOptionalResult {
592
+ type: 'OPTIONAL';
593
+ value: JtpResult;
594
+ meta: {
595
+ syntax: 'PREFIX_EQUAL_SIGN' | 'SUFFIX_EQUALS_SIGN' | 'SUFFIX_KEY_QUESTION_MARK';
596
+ };
597
+ }
598
+ interface JtpVariadicResult {
599
+ type: 'VARIADIC';
600
+ value?: JtpResult;
601
+ meta: {
602
+ syntax: 'PREFIX_DOTS' | 'SUFFIX_DOTS' | 'ONLY_DOTS';
603
+ };
604
+ }
605
+ interface JtpNameResult {
606
+ type: 'NAME';
607
+ name: string;
608
+ }
609
+ interface JtpTypeOfResult {
610
+ type: 'TYPE_QUERY';
611
+ name?: JtpResult;
612
+ }
613
+ interface JtpKeyOfResult {
614
+ type: 'KEY_QUERY';
615
+ value?: JtpResult;
616
+ }
617
+ interface JtpTupleResult {
618
+ type: 'TUPLE';
619
+ entries: JtpResult[];
620
+ }
621
+ interface JtpStringValueResult {
622
+ type: 'STRING_VALUE';
623
+ quoteStyle: JtpQuoteStyle;
624
+ string: string;
625
+ }
626
+ interface JtpImportResult {
627
+ type: 'IMPORT';
628
+ path: JtpStringValueResult;
629
+ }
630
+ interface JtpAnyResult {
631
+ type: 'ANY';
632
+ }
633
+ interface JtpUnknownResult {
634
+ type: 'UNKNOWN';
635
+ }
636
+ interface JtpFunctionResult {
637
+ type: 'FUNCTION' | 'ARROW';
638
+ params: JtpResult[];
639
+ returns: JtpResult | null;
640
+ new: JtpResult | null;
641
+ this?: JtpResult | null;
642
+ }
643
+ interface JtpGenericResult {
644
+ type: 'GENERIC';
645
+ subject: JtpResult;
646
+ objects: JtpResult[];
647
+ meta: {
648
+ syntax: 'ANGLE_BRACKET' | 'ANGLE_BRACKET_WITH_DOT' | 'SQUARE_BRACKET';
649
+ };
650
+ }
651
+ interface JtpRecordEntryResult {
652
+ type: 'RECORD_ENTRY';
653
+ key: string;
654
+ quoteStyle: JtpQuoteStyle;
655
+ value: JtpResult | null;
656
+ readonly: false;
657
+ }
658
+ interface JtpRecordResult {
659
+ type: 'RECORD';
660
+ entries: JtpRecordEntryResult[];
661
+ }
662
+ interface JtpMemberResult {
663
+ type: 'MEMBER' | 'INNER_MEMBER' | 'INSTANCE_MEMBER';
664
+ owner: JtpResult;
665
+ name: string;
666
+ quoteStyle: JtpQuoteStyle;
667
+ hasEventPrefix: boolean;
668
+ }
669
+ interface JtpUnionResult {
670
+ type: 'UNION';
671
+ left: JtpResult;
672
+ right: JtpResult;
673
+ }
674
+ interface JtpIntersectionResult {
675
+ type: 'INTERSECTION';
676
+ left: JtpResult;
677
+ right: JtpResult;
678
+ }
679
+ interface JtpParenthesisResult {
680
+ type: 'PARENTHESIS';
681
+ value: JtpResult;
682
+ }
683
+ interface JtpNamedParameterResult {
684
+ type: 'NAMED_PARAMETER';
685
+ name: string;
686
+ typeName: JtpResult;
687
+ }
688
+ interface JtpModuleResult {
689
+ type: 'MODULE';
690
+ value: JtpResult;
691
+ }
692
+ interface JtpFilePath {
693
+ type: 'FILE_PATH';
694
+ quoteStyle: JtpQuoteStyle;
695
+ path: string;
696
+ }
697
+ interface JtpNumberResult {
698
+ type: 'NUMBER_VALUE';
699
+ number: string;
700
+ }
701
+ declare function jtpTransform(result: RootResult): JtpResult;
702
+ //#endregion
703
+ //#region src/transforms/stringify.d.ts
704
+ declare function stringifyRules({ computedPropertyStringifier }?: {
705
+ computedPropertyStringifier?: (node: Node, options?: any) => string;
706
+ }): TransformRules<string>;
707
+ declare function stringify(result: RootResult, stringificationRules?: TransformRules<string> | ((node: Node, options?: any) => string)): string;
708
+ //#endregion
709
+ //#region src/transforms/identityTransformRules.d.ts
710
+ declare function identityTransformRules(): TransformRules<NonRootResult>;
711
+ //#endregion
712
+ //#region src/traverse.d.ts
713
+ /**
714
+ * A node visitor function.
715
+ * @param node the visited node.
716
+ * @param parentNode the parent node.
717
+ * @param property the property on the parent node that contains the visited node. It can be the node itself or
718
+ * an array of nodes.
719
+ */
720
+ type NodeVisitor = (node: NonRootResult, parentNode?: NonRootResult, property?: string, index?: number) => void;
721
+ /**
722
+ * A function to traverse an AST. It traverses it depth first.
723
+ * @param node the node to start traversing at.
724
+ * @param onEnter node visitor function that will be called on entering the node. This corresponds to preorder traversing.
725
+ * @param onLeave node visitor function that will be called on leaving the node. This corresponds to postorder traversing.
726
+ */
727
+ declare function traverse(node: RootResult, onEnter?: NodeVisitor, onLeave?: NodeVisitor): void;
728
+ //#endregion
729
+ //#region src/visitorKeys.d.ts
730
+ type VisitorKeys = { [P in NonRootResult as P['type']]: Array<keyof P>; };
731
+ declare const visitorKeys: VisitorKeys;
732
+ //#endregion
733
+ export { type AnyResult, type AssertsPlainResult, type AssertsResult, type BaseNode, type BigIntResult, type CallSignatureResult, type ComputedMethodResult, type ComputedPropertyResult, type ConditionalResult, type ConstructorSignatureResult, type FunctionResult, type GenericResult, type ImportResult, type IndexSignatureResult, type IndexedAccessIndexResult, type InferResult, type IntersectionResult, type JsdocObjectFieldResult, type KeyOfResult, type KeyValueResult, type Location, type MappedTypeResult, type MethodSignatureResult, type NamePathResult, type NameResult, NodeVisitor, type NonRootResult, type NotNullableResult, type NullResult, type NullableResult, type NumberResult, type ObjectFieldResult, type ObjectResult, type OptionalResult, type ParenthesisResult, ParseMode, type PredicateResult, type PropertyResult, type QuoteStyle, type Range, type ReadonlyArrayResult, type RootResult, type SpecialNamePath, type SpecialNamePathType, type StringValueResult, type SymbolResult, type TemplateLiteralResult, type TransformFunction, type TransformRule, type TransformRules, type TupleResult, type TypeOfResult, type TypeParameterResult, type UndefinedResult, type UnionResult, type UniqueSymbolResult, type UnknownResult, type VariadicResult, VisitorKeys, catharsisTransform, identityTransformRules, jtpTransform, parse, parseName, parseNamePath, stringify, stringifyRules, transform, traverse, tryParse, visitorKeys };