ripple 0.2.183 → 0.2.185
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/package.json +2 -2
- package/src/compiler/phases/2-analyze/index.js +7 -2
- package/src/compiler/phases/3-transform/client/index.js +181 -131
- package/src/compiler/phases/3-transform/segments.js +93 -49
- package/src/compiler/phases/3-transform/server/index.js +135 -45
- package/src/compiler/scope.js +11 -16
- package/src/compiler/types/index.d.ts +333 -90
- package/src/compiler/types/parse.d.ts +127 -9
- package/src/runtime/index-server.js +10 -27
- package/src/runtime/internal/client/operations.js +1 -1
- package/src/runtime/internal/client/runtime.js +8 -8
- package/src/runtime/internal/client/types.d.ts +5 -5
- package/src/runtime/internal/server/index.js +268 -17
- package/src/runtime/internal/server/types.d.ts +19 -11
- package/tests/client/switch.test.ripple +73 -23
- package/tests/server/basic.test.ripple +119 -0
- package/tests/server/composite.test.ripple +1 -1
- package/tests/server/context.test.ripple +31 -0
- package/tests/server/switch.test.ripple +21 -0
|
@@ -3,6 +3,7 @@ import type * as ESTreeJSX from 'estree-jsx';
|
|
|
3
3
|
import type { TSESTree } from '@typescript-eslint/types';
|
|
4
4
|
import type { NAMESPACE_URI } from '../../runtime/internal/client/constants.js';
|
|
5
5
|
import type { Parse } from '#parser';
|
|
6
|
+
import type * as ESRap from 'esrap';
|
|
6
7
|
|
|
7
8
|
export type RpcModules = Map<string, [string, string]>;
|
|
8
9
|
|
|
@@ -61,13 +62,29 @@ declare module 'estree' {
|
|
|
61
62
|
metadata: FunctionMetaData;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
interface MethodDefinition {
|
|
66
|
+
typeParameters?: TSTypeParameterDeclaration;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ClassDeclaration {
|
|
70
|
+
typeParameters?: AST.TSTypeParameterDeclaration;
|
|
71
|
+
superTypeArguments?: AST.TSTypeParameterInstantiation;
|
|
72
|
+
implements?: AST.TSClassImplements[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ClassExpression {
|
|
76
|
+
typeParameters?: AST.TSTypeParameterDeclaration;
|
|
77
|
+
superTypeArguments?: AST.TSTypeParameterInstantiation;
|
|
78
|
+
implements?: AST.TSClassImplements[];
|
|
79
|
+
}
|
|
80
|
+
|
|
64
81
|
interface Identifier extends TrackedNode {
|
|
65
82
|
metadata: BaseNode['metadata'] & {
|
|
66
83
|
tracked_shorthand?: '#Map' | '#Set';
|
|
67
84
|
};
|
|
68
85
|
}
|
|
69
86
|
|
|
70
|
-
interface MemberExpression extends TrackedNode {}
|
|
87
|
+
interface MemberExpression extends AST.TrackedNode {}
|
|
71
88
|
|
|
72
89
|
interface TrackedNode {
|
|
73
90
|
tracked?: boolean;
|
|
@@ -86,7 +103,7 @@ declare module 'estree' {
|
|
|
86
103
|
Attribute: Attribute;
|
|
87
104
|
RefAttribute: RefAttribute;
|
|
88
105
|
SpreadAttribute: SpreadAttribute;
|
|
89
|
-
|
|
106
|
+
ParenthesizedExpression: ParenthesizedExpression;
|
|
90
107
|
}
|
|
91
108
|
|
|
92
109
|
interface ExpressionMap {
|
|
@@ -98,6 +115,12 @@ declare module 'estree' {
|
|
|
98
115
|
Text: TextNode;
|
|
99
116
|
}
|
|
100
117
|
|
|
118
|
+
// Missing estree type
|
|
119
|
+
interface ParenthesizedExpression extends AST.BaseNode {
|
|
120
|
+
type: 'ParenthesizedExpression';
|
|
121
|
+
expression: AST.Expression;
|
|
122
|
+
}
|
|
123
|
+
|
|
101
124
|
interface Comment {
|
|
102
125
|
context?: Parse.CommentMetaData | null;
|
|
103
126
|
}
|
|
@@ -105,18 +128,18 @@ declare module 'estree' {
|
|
|
105
128
|
/**
|
|
106
129
|
* Custom Comment interface with location information
|
|
107
130
|
*/
|
|
108
|
-
type CommentWithLocation = Comment & NodeWithLocation;
|
|
131
|
+
type CommentWithLocation = AST.Comment & NodeWithLocation;
|
|
109
132
|
|
|
110
133
|
interface TryStatement {
|
|
111
|
-
pending?: BlockStatement | null;
|
|
134
|
+
pending?: AST.BlockStatement | null;
|
|
112
135
|
}
|
|
113
136
|
|
|
114
137
|
interface ForOfStatement {
|
|
115
|
-
index?: Identifier | null;
|
|
116
|
-
key?: Expression | null;
|
|
138
|
+
index?: AST.Identifier | null;
|
|
139
|
+
key?: AST.Expression | null;
|
|
117
140
|
}
|
|
118
141
|
|
|
119
|
-
interface ServerIdentifier extends BaseNode {
|
|
142
|
+
interface ServerIdentifier extends AST.BaseNode {
|
|
120
143
|
type: 'ServerIdentifier';
|
|
121
144
|
}
|
|
122
145
|
|
|
@@ -154,24 +177,24 @@ declare module 'estree' {
|
|
|
154
177
|
// to avoid lots of typecasting or checking for undefined
|
|
155
178
|
metadata: BaseNodeMetaData;
|
|
156
179
|
|
|
157
|
-
comments?:
|
|
180
|
+
comments?: Comment[];
|
|
158
181
|
}
|
|
159
182
|
|
|
160
183
|
interface NodeWithLocation {
|
|
161
184
|
start: number;
|
|
162
185
|
end: number;
|
|
163
|
-
loc: SourceLocation;
|
|
186
|
+
loc: AST.SourceLocation;
|
|
164
187
|
}
|
|
165
188
|
|
|
166
189
|
/**
|
|
167
190
|
* Ripple custom interfaces and types section
|
|
168
191
|
*/
|
|
169
|
-
interface Component extends BaseNode {
|
|
192
|
+
interface Component extends AST.BaseNode {
|
|
170
193
|
type: 'Component';
|
|
171
194
|
// null is for anonymous components {component: () => {}}
|
|
172
|
-
id: Identifier | null;
|
|
173
|
-
params: Pattern[];
|
|
174
|
-
body: Node[];
|
|
195
|
+
id: AST.Identifier | null;
|
|
196
|
+
params: AST.Pattern[];
|
|
197
|
+
body: AST.Node[];
|
|
175
198
|
css: CSS.StyleSheet | null;
|
|
176
199
|
metadata: BaseNodeMetaData & {
|
|
177
200
|
inherited_css?: boolean;
|
|
@@ -179,7 +202,7 @@ declare module 'estree' {
|
|
|
179
202
|
default: boolean;
|
|
180
203
|
}
|
|
181
204
|
|
|
182
|
-
interface TsxCompat extends BaseNode {
|
|
205
|
+
interface TsxCompat extends AST.BaseNode {
|
|
183
206
|
type: 'TsxCompat';
|
|
184
207
|
kind: string;
|
|
185
208
|
attributes: Array<any>;
|
|
@@ -188,19 +211,19 @@ declare module 'estree' {
|
|
|
188
211
|
unclosed?: boolean;
|
|
189
212
|
}
|
|
190
213
|
|
|
191
|
-
interface Html extends BaseNode {
|
|
214
|
+
interface Html extends AST.BaseNode {
|
|
192
215
|
type: 'Html';
|
|
193
216
|
expression: Expression;
|
|
194
217
|
}
|
|
195
218
|
|
|
196
|
-
interface Element extends BaseNode {
|
|
219
|
+
interface Element extends AST.BaseNode {
|
|
197
220
|
type: 'Element';
|
|
198
|
-
id: Identifier;
|
|
221
|
+
id: AST.Identifier;
|
|
199
222
|
attributes: RippleAttribute[];
|
|
200
|
-
children: Node[];
|
|
223
|
+
children: AST.Node[];
|
|
201
224
|
selfClosing?: boolean;
|
|
202
225
|
unclosed?: boolean;
|
|
203
|
-
loc:
|
|
226
|
+
loc: SourceLocation;
|
|
204
227
|
metadata: BaseNodeMetaData & {
|
|
205
228
|
ts_name?: string;
|
|
206
229
|
};
|
|
@@ -220,11 +243,11 @@ declare module 'estree' {
|
|
|
220
243
|
|
|
221
244
|
export interface TextNode extends AST.BaseNode {
|
|
222
245
|
type: 'Text';
|
|
223
|
-
expression: Expression;
|
|
224
|
-
loc?: SourceLocation;
|
|
246
|
+
expression: AST.Expression;
|
|
247
|
+
loc?: AST.SourceLocation;
|
|
225
248
|
}
|
|
226
249
|
|
|
227
|
-
interface ServerBlock extends BaseNode {
|
|
250
|
+
interface ServerBlock extends AST.BaseNode {
|
|
228
251
|
type: 'ServerBlock';
|
|
229
252
|
body: BlockStatement;
|
|
230
253
|
metadata: BaseNodeMetaData & {
|
|
@@ -235,62 +258,62 @@ declare module 'estree' {
|
|
|
235
258
|
/**
|
|
236
259
|
* Tracked Expressions
|
|
237
260
|
*/
|
|
238
|
-
interface TrackedArrayExpression extends Omit<ArrayExpression, 'type'> {
|
|
261
|
+
interface TrackedArrayExpression extends Omit<AST.ArrayExpression, 'type'> {
|
|
239
262
|
type: 'TrackedArrayExpression';
|
|
240
|
-
elements: (Expression | SpreadElement | null)[];
|
|
263
|
+
elements: (AST.Expression | AST.SpreadElement | null)[];
|
|
241
264
|
}
|
|
242
265
|
|
|
243
|
-
interface TrackedExpression extends BaseNode {
|
|
244
|
-
argument: Expression;
|
|
266
|
+
interface TrackedExpression extends AST.BaseNode {
|
|
267
|
+
argument: AST.Expression;
|
|
245
268
|
type: 'TrackedExpression';
|
|
246
269
|
}
|
|
247
270
|
|
|
248
|
-
interface TrackedObjectExpression extends Omit<ObjectExpression, 'type'> {
|
|
271
|
+
interface TrackedObjectExpression extends Omit<AST.ObjectExpression, 'type'> {
|
|
249
272
|
type: 'TrackedObjectExpression';
|
|
250
|
-
properties: (Property | SpreadElement)[];
|
|
273
|
+
properties: (AST.Property | AST.SpreadElement)[];
|
|
251
274
|
}
|
|
252
275
|
|
|
253
|
-
interface TrackedMapExpression extends BaseNode {
|
|
276
|
+
interface TrackedMapExpression extends AST.BaseNode {
|
|
254
277
|
type: 'TrackedMapExpression';
|
|
255
|
-
arguments: (Expression | SpreadElement)[];
|
|
278
|
+
arguments: (AST.Expression | AST.SpreadElement)[];
|
|
256
279
|
}
|
|
257
280
|
|
|
258
|
-
interface TrackedSetExpression extends BaseNode {
|
|
281
|
+
interface TrackedSetExpression extends AST.BaseNode {
|
|
259
282
|
type: 'TrackedSetExpression';
|
|
260
|
-
arguments: (Expression | SpreadElement)[];
|
|
283
|
+
arguments: (AST.Expression | AST.SpreadElement)[];
|
|
261
284
|
}
|
|
262
285
|
|
|
263
286
|
/**
|
|
264
287
|
* Ripple attribute nodes
|
|
265
288
|
*/
|
|
266
|
-
interface Attribute extends BaseNode {
|
|
289
|
+
interface Attribute extends AST.BaseNode {
|
|
267
290
|
type: 'Attribute';
|
|
268
|
-
name: Identifier;
|
|
269
|
-
value: Expression | null;
|
|
270
|
-
loc?: SourceLocation;
|
|
291
|
+
name: AST.Identifier;
|
|
292
|
+
value: AST.Expression | null;
|
|
293
|
+
loc?: AST.SourceLocation;
|
|
271
294
|
shorthand?: boolean;
|
|
272
295
|
metadata: BaseNodeMetaData & {
|
|
273
296
|
delegated?: boolean;
|
|
274
297
|
};
|
|
275
298
|
}
|
|
276
299
|
|
|
277
|
-
interface RefAttribute extends BaseNode {
|
|
300
|
+
interface RefAttribute extends AST.BaseNode {
|
|
278
301
|
type: 'RefAttribute';
|
|
279
|
-
argument: Expression;
|
|
280
|
-
loc?: SourceLocation;
|
|
302
|
+
argument: AST.Expression;
|
|
303
|
+
loc?: AST.SourceLocation;
|
|
281
304
|
}
|
|
282
305
|
|
|
283
|
-
interface SpreadAttribute extends BaseNode {
|
|
306
|
+
interface SpreadAttribute extends AST.BaseNode {
|
|
284
307
|
type: 'SpreadAttribute';
|
|
285
|
-
argument: Expression;
|
|
286
|
-
loc?: SourceLocation;
|
|
308
|
+
argument: AST.Expression;
|
|
309
|
+
loc?: AST.SourceLocation;
|
|
287
310
|
}
|
|
288
311
|
|
|
289
312
|
/**
|
|
290
313
|
* Ripple's extended Declaration type that includes Component
|
|
291
|
-
* Use this instead of
|
|
314
|
+
* Use this instead of Declaration when you need Component support
|
|
292
315
|
*/
|
|
293
|
-
export type RippleDeclaration = AST.Declaration |
|
|
316
|
+
export type RippleDeclaration = AST.Declaration | Component | AST.TSDeclareFunction;
|
|
294
317
|
|
|
295
318
|
/**
|
|
296
319
|
* Ripple's extended ExportNamedDeclaration with Component support
|
|
@@ -302,8 +325,8 @@ declare module 'estree' {
|
|
|
302
325
|
/**
|
|
303
326
|
* Ripple's extended Program with Component support
|
|
304
327
|
*/
|
|
305
|
-
interface RippleProgram extends Omit<
|
|
306
|
-
body: (
|
|
328
|
+
interface RippleProgram extends Omit<Program, 'body'> {
|
|
329
|
+
body: (Program['body'][number] | Component)[];
|
|
307
330
|
}
|
|
308
331
|
|
|
309
332
|
export type RippleAttribute = Attribute | SpreadAttribute | RefAttribute;
|
|
@@ -485,7 +508,7 @@ declare module 'estree-jsx' {
|
|
|
485
508
|
|
|
486
509
|
interface JSXEmptyExpression {
|
|
487
510
|
loc: AST.SourceLocation;
|
|
488
|
-
innerComments?: Comment[];
|
|
511
|
+
innerComments?: AST.Comment[];
|
|
489
512
|
}
|
|
490
513
|
|
|
491
514
|
interface JSXOpeningFragment {
|
|
@@ -512,7 +535,9 @@ declare module 'estree-jsx' {
|
|
|
512
535
|
}
|
|
513
536
|
|
|
514
537
|
declare module 'estree' {
|
|
515
|
-
|
|
538
|
+
// Helper map for creating our own TypeNode
|
|
539
|
+
// and to be used to extend estree's NodeMap
|
|
540
|
+
interface TSNodeMap {
|
|
516
541
|
// TypeScript nodes
|
|
517
542
|
TSAnyKeyword: TSAnyKeyword;
|
|
518
543
|
TSArrayType: TSArrayType;
|
|
@@ -577,49 +602,196 @@ declare module 'estree' {
|
|
|
577
602
|
TSUnknownKeyword: TSUnknownKeyword;
|
|
578
603
|
TSVoidKeyword: TSVoidKeyword;
|
|
579
604
|
TSParenthesizedType: TSParenthesizedType;
|
|
605
|
+
TSExpressionWithTypeArguments: TSExpressionWithTypeArguments;
|
|
606
|
+
TSClassImplements: TSClassImplements;
|
|
580
607
|
}
|
|
581
608
|
|
|
609
|
+
// Create our version of TypeNode with modified types to be used in replacements
|
|
610
|
+
type TypeNode = TSNodeMap[keyof TSNodeMap];
|
|
611
|
+
|
|
612
|
+
// Extend NodeMap to include TypeScript nodes
|
|
613
|
+
interface NodeMap extends TSNodeMap {
|
|
614
|
+
TypeNode: TypeNode;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
type EntityName = AST.Identifier | AST.ThisExpression | TSQualifiedName;
|
|
618
|
+
type Parameter =
|
|
619
|
+
| AST.ArrayPattern
|
|
620
|
+
| AST.AssignmentPattern
|
|
621
|
+
| AST.Identifier
|
|
622
|
+
| AST.ObjectPattern
|
|
623
|
+
| AST.RestElement
|
|
624
|
+
| TSParameterProperty;
|
|
625
|
+
type TypeElement =
|
|
626
|
+
| TSCallSignatureDeclaration
|
|
627
|
+
| TSConstructSignatureDeclaration
|
|
628
|
+
| TSIndexSignature
|
|
629
|
+
| TSMethodSignature
|
|
630
|
+
| TSPropertySignature;
|
|
631
|
+
type TSPropertySignature = TSPropertySignatureComputedName | TSPropertySignatureNonComputedName;
|
|
632
|
+
type PropertyNameComputed = AST.Expression;
|
|
633
|
+
type PropertyNameNonComputed = AST.Identifier | NumberLiteral | StringLiteral;
|
|
634
|
+
|
|
582
635
|
// TypeScript AST node interfaces from @sveltejs/acorn-typescript
|
|
583
636
|
// Based on TSESTree types but adapted for acorn's output format
|
|
584
637
|
interface TSAnyKeyword extends AcornTSNode<TSESTree.TSAnyKeyword> {}
|
|
585
|
-
interface TSArrayType extends AcornTSNode<TSESTree.TSArrayType> {
|
|
638
|
+
interface TSArrayType extends Omit<AcornTSNode<TSESTree.TSArrayType>, 'elementType'> {
|
|
639
|
+
elementType: TypeNode;
|
|
640
|
+
}
|
|
586
641
|
interface TSAsExpression extends AcornTSNode<TSESTree.TSAsExpression> {
|
|
587
642
|
// Have to override it to use our Expression for required properties like metadata
|
|
588
643
|
expression: AST.Expression;
|
|
589
644
|
}
|
|
590
645
|
interface TSBigIntKeyword extends AcornTSNode<TSESTree.TSBigIntKeyword> {}
|
|
591
646
|
interface TSBooleanKeyword extends AcornTSNode<TSESTree.TSBooleanKeyword> {}
|
|
592
|
-
interface TSCallSignatureDeclaration
|
|
593
|
-
|
|
594
|
-
|
|
647
|
+
interface TSCallSignatureDeclaration
|
|
648
|
+
extends Omit<
|
|
649
|
+
AcornTSNode<TSESTree.TSCallSignatureDeclaration>,
|
|
650
|
+
'typeParameters' | 'typeAnnotation'
|
|
651
|
+
> {
|
|
652
|
+
parameters: Parameter[];
|
|
653
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
654
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
655
|
+
}
|
|
656
|
+
interface TSConditionalType
|
|
657
|
+
extends Omit<
|
|
658
|
+
AcornTSNode<TSESTree.TSConditionalType>,
|
|
659
|
+
'checkType' | 'extendsType' | 'falseType' | 'trueType'
|
|
660
|
+
> {
|
|
661
|
+
checkType: TypeNode;
|
|
662
|
+
extendsType: TypeNode;
|
|
663
|
+
falseType: TypeNode;
|
|
664
|
+
trueType: TypeNode;
|
|
665
|
+
}
|
|
666
|
+
interface TSConstructorType
|
|
667
|
+
extends Omit<AcornTSNode<TSESTree.TSConstructorType>, 'typeParameters' | 'params'> {
|
|
668
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
669
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
670
|
+
parameters: AST.Parameter[];
|
|
671
|
+
}
|
|
595
672
|
interface TSConstructSignatureDeclaration
|
|
596
|
-
extends
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
673
|
+
extends Omit<
|
|
674
|
+
AcornTSNode<TSESTree.TSConstructSignatureDeclaration>,
|
|
675
|
+
'typeParameters' | 'typeAnnotation'
|
|
676
|
+
> {
|
|
677
|
+
parameters: Parameter[];
|
|
678
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
679
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
680
|
+
}
|
|
681
|
+
interface TSDeclareFunction
|
|
682
|
+
extends Omit<
|
|
683
|
+
AcornTSNode<TSESTree.TSDeclareFunction>,
|
|
684
|
+
'id' | 'params' | 'typeParameters' | 'returnType'
|
|
685
|
+
> {
|
|
686
|
+
id: AST.Identifier;
|
|
687
|
+
params: Parameter[];
|
|
688
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
689
|
+
returnType: TSTypeAnnotation | undefined;
|
|
690
|
+
}
|
|
691
|
+
interface TSEnumDeclaration
|
|
692
|
+
extends Omit<AcornTSNode<TSESTree.TSEnumDeclaration>, 'id' | 'members'> {
|
|
693
|
+
id: AST.Identifier;
|
|
694
|
+
members: TSEnumMember[];
|
|
695
|
+
}
|
|
696
|
+
interface TSEnumMember extends Omit<AcornTSNode<TSESTree.TSEnumMember>, 'id' | 'initializer'> {
|
|
697
|
+
id: AST.Identifier | StringLiteral;
|
|
698
|
+
initializer: AST.Expression | undefined;
|
|
699
|
+
}
|
|
700
|
+
interface TSExportAssignment
|
|
701
|
+
extends Omit<AcornTSNode<TSESTree.TSExportAssignment>, 'expression'> {
|
|
702
|
+
expression: AST.Expression;
|
|
703
|
+
}
|
|
704
|
+
interface TSExternalModuleReference
|
|
705
|
+
extends Omit<AcornTSNode<TSESTree.TSExternalModuleReference>, 'expression'> {
|
|
706
|
+
expression: StringLiteral;
|
|
707
|
+
}
|
|
708
|
+
interface TSFunctionType
|
|
709
|
+
extends Omit<AcornTSNode<TSESTree.TSFunctionType>, 'typeParameters' | 'params'> {
|
|
710
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
711
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
712
|
+
parameters: Parameter[];
|
|
713
|
+
}
|
|
603
714
|
interface TSImportEqualsDeclaration extends AcornTSNode<TSESTree.TSImportEqualsDeclaration> {}
|
|
604
|
-
interface TSImportType
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
715
|
+
interface TSImportType
|
|
716
|
+
extends Omit<AcornTSNode<TSESTree.TSImportType>, 'argument' | 'qualifier' | 'typeParameters'> {
|
|
717
|
+
argument: TypeNode;
|
|
718
|
+
qualifier: EntityName | null;
|
|
719
|
+
// looks like acorn-typescript has typeParameters
|
|
720
|
+
typeParameters: TSTypeParameterDeclaration | undefined | undefined;
|
|
721
|
+
}
|
|
722
|
+
interface TSIndexedAccessType
|
|
723
|
+
extends Omit<AcornTSNode<TSESTree.TSIndexedAccessType>, 'indexType' | 'objectType'> {
|
|
724
|
+
indexType: TypeNode;
|
|
725
|
+
objectType: TypeNode;
|
|
726
|
+
}
|
|
727
|
+
interface TSIndexSignature
|
|
728
|
+
extends Omit<AcornTSNode<TSESTree.TSIndexSignature>, 'parameters' | 'typeAnnotation'> {
|
|
729
|
+
parameters: AST.Parameter[];
|
|
730
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
731
|
+
}
|
|
732
|
+
interface TSInferType extends Omit<AcornTSNode<TSESTree.TSInferType>, 'typeParameter'> {
|
|
733
|
+
typeParameter: TSTypeParameter;
|
|
734
|
+
}
|
|
608
735
|
interface TSInstantiationExpression extends AcornTSNode<TSESTree.TSInstantiationExpression> {
|
|
609
736
|
expression: AST.Expression;
|
|
610
737
|
}
|
|
611
|
-
interface TSInterfaceBody extends AcornTSNode<TSESTree.TSInterfaceBody> {
|
|
612
|
-
|
|
613
|
-
|
|
738
|
+
interface TSInterfaceBody extends Omit<AcornTSNode<TSESTree.TSInterfaceBody>, 'body'> {
|
|
739
|
+
body: TypeElement[];
|
|
740
|
+
}
|
|
741
|
+
interface TSInterfaceDeclaration
|
|
742
|
+
extends Omit<
|
|
743
|
+
AcornTSNode<TSESTree.TSInterfaceDeclaration>,
|
|
744
|
+
'id' | 'typeParameters' | 'body' | 'extends'
|
|
745
|
+
> {
|
|
746
|
+
id: AST.Identifier;
|
|
747
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
748
|
+
body: TSInterfaceBody;
|
|
749
|
+
extends: TSExpressionWithTypeArguments[];
|
|
750
|
+
}
|
|
751
|
+
interface TSIntersectionType extends Omit<AcornTSNode<TSESTree.TSIntersectionType>, 'types'> {
|
|
752
|
+
types: TypeNode[];
|
|
753
|
+
}
|
|
614
754
|
interface TSIntrinsicKeyword extends AcornTSNode<TSESTree.TSIntrinsicKeyword> {}
|
|
615
|
-
interface TSLiteralType extends AcornTSNode<TSESTree.TSLiteralType> {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
interface
|
|
619
|
-
|
|
620
|
-
|
|
755
|
+
interface TSLiteralType extends Omit<AcornTSNode<TSESTree.TSLiteralType>, 'literal'> {
|
|
756
|
+
literal: AST.Literal | AST.TemplateLiteral;
|
|
757
|
+
}
|
|
758
|
+
interface TSMappedType
|
|
759
|
+
extends Omit<
|
|
760
|
+
AcornTSNode<TSESTree.TSMappedType>,
|
|
761
|
+
'typeParameter' | 'typeAnnotation' | 'nameType'
|
|
762
|
+
> {
|
|
763
|
+
typeAnnotation: TypeNode | undefined;
|
|
764
|
+
typeParameter: TSTypeParameter;
|
|
765
|
+
nameType: TypeNode | null;
|
|
766
|
+
}
|
|
767
|
+
interface TSMethodSignature
|
|
768
|
+
extends Omit<
|
|
769
|
+
AcornTSNode<TSESTree.TSMethodSignature>,
|
|
770
|
+
'key' | 'typeParameters' | 'params' | 'typeAnnotation'
|
|
771
|
+
> {
|
|
772
|
+
key: PropertyNameComputed | PropertyNameNonComputed;
|
|
773
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
774
|
+
parameters: Parameter[];
|
|
775
|
+
// doesn't actually exist in the spec but acorn-typescript adds it
|
|
776
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
777
|
+
}
|
|
778
|
+
interface TSModuleBlock extends Omit<AcornTSNode<TSESTree.TSModuleBlock>, 'body'> {
|
|
779
|
+
body: AST.Statement[];
|
|
780
|
+
}
|
|
781
|
+
interface TSModuleDeclaration
|
|
782
|
+
extends Omit<AcornTSNode<TSESTree.TSModuleDeclaration>, 'body' | 'id'> {
|
|
783
|
+
body: TSModuleBlock;
|
|
784
|
+
id: AST.Identifier;
|
|
785
|
+
}
|
|
786
|
+
interface TSNamedTupleMember
|
|
787
|
+
extends Omit<AcornTSNode<TSESTree.TSNamedTupleMember>, 'elementType' | 'label'> {
|
|
788
|
+
elementType: TypeNode;
|
|
789
|
+
label: AST.Identifier;
|
|
790
|
+
}
|
|
621
791
|
interface TSNamespaceExportDeclaration
|
|
622
|
-
extends AcornTSNode<TSESTree.TSNamespaceExportDeclaration> {
|
|
792
|
+
extends Omit<AcornTSNode<TSESTree.TSNamespaceExportDeclaration>, 'id'> {
|
|
793
|
+
id: AST.Identifier;
|
|
794
|
+
}
|
|
623
795
|
interface TSNeverKeyword extends AcornTSNode<TSESTree.TSNeverKeyword> {}
|
|
624
796
|
interface TSNonNullExpression extends AcornTSNode<TSESTree.TSNonNullExpression> {
|
|
625
797
|
expression: AST.Expression;
|
|
@@ -627,36 +799,107 @@ declare module 'estree' {
|
|
|
627
799
|
interface TSNullKeyword extends AcornTSNode<TSESTree.TSNullKeyword> {}
|
|
628
800
|
interface TSNumberKeyword extends AcornTSNode<TSESTree.TSNumberKeyword> {}
|
|
629
801
|
interface TSObjectKeyword extends AcornTSNode<TSESTree.TSObjectKeyword> {}
|
|
630
|
-
interface TSOptionalType extends AcornTSNode<TSESTree.TSOptionalType> {
|
|
802
|
+
interface TSOptionalType extends Omit<AcornTSNode<TSESTree.TSOptionalType>, 'typeAnnotation'> {
|
|
803
|
+
typeAnnotation: TypeNode;
|
|
804
|
+
}
|
|
631
805
|
interface TSParameterProperty extends AcornTSNode<TSESTree.TSParameterProperty> {}
|
|
632
|
-
interface
|
|
633
|
-
|
|
634
|
-
|
|
806
|
+
interface TSPropertySignatureComputedName
|
|
807
|
+
extends Omit<AcornTSNode<TSESTree.TSPropertySignatureComputedName>, 'key' | 'typeAnnotation'> {
|
|
808
|
+
key: PropertyNameComputed;
|
|
809
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
810
|
+
}
|
|
811
|
+
interface TSPropertySignatureNonComputedName
|
|
812
|
+
extends Omit<
|
|
813
|
+
AcornTSNode<TSESTree.TSPropertySignatureNonComputedName>,
|
|
814
|
+
'key' | 'typeAnnotation'
|
|
815
|
+
> {
|
|
816
|
+
key: PropertyNameNonComputed;
|
|
817
|
+
typeAnnotation: TSTypeAnnotation | undefined;
|
|
818
|
+
}
|
|
819
|
+
interface TSQualifiedName extends Omit<AcornTSNode<TSESTree.TSQualifiedName>, 'left' | 'right'> {
|
|
820
|
+
left: EntityName;
|
|
821
|
+
right: AST.Identifier;
|
|
822
|
+
}
|
|
823
|
+
interface TSRestType extends Omit<AcornTSNode<TSESTree.TSRestType>, 'typeAnnotation'> {
|
|
824
|
+
typeAnnotation: TypeNode;
|
|
825
|
+
}
|
|
635
826
|
interface TSSatisfiesExpression extends AcornTSNode<TSESTree.TSSatisfiesExpression> {
|
|
636
827
|
expression: AST.Expression;
|
|
637
828
|
}
|
|
638
829
|
interface TSStringKeyword extends AcornTSNode<TSESTree.TSStringKeyword> {}
|
|
639
830
|
interface TSSymbolKeyword extends AcornTSNode<TSESTree.TSSymbolKeyword> {}
|
|
640
831
|
interface TSThisType extends AcornTSNode<TSESTree.TSThisType> {}
|
|
641
|
-
interface TSTupleType extends AcornTSNode<TSESTree.TSTupleType> {
|
|
642
|
-
|
|
643
|
-
|
|
832
|
+
interface TSTupleType extends Omit<AcornTSNode<TSESTree.TSTupleType>, 'elementTypes'> {
|
|
833
|
+
elementTypes: TypeNode[];
|
|
834
|
+
}
|
|
835
|
+
interface TSTypeAliasDeclaration
|
|
836
|
+
extends Omit<
|
|
837
|
+
AcornTSNode<TSESTree.TSTypeAliasDeclaration>,
|
|
838
|
+
'id' | 'typeParameters' | 'typeAnnotation'
|
|
839
|
+
> {
|
|
840
|
+
id: AST.Identifier;
|
|
841
|
+
typeAnnotation: TypeNode;
|
|
842
|
+
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
843
|
+
}
|
|
844
|
+
interface TSTypeAnnotation
|
|
845
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeAnnotation>, 'typeAnnotation'> {
|
|
846
|
+
typeAnnotation: TypeNode;
|
|
847
|
+
}
|
|
644
848
|
interface TSTypeAssertion extends AcornTSNode<TSESTree.TSTypeAssertion> {
|
|
645
849
|
expression: AST.Expression;
|
|
646
850
|
}
|
|
647
|
-
interface TSTypeLiteral extends AcornTSNode<TSESTree.TSTypeLiteral> {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
interface
|
|
851
|
+
interface TSTypeLiteral extends Omit<AcornTSNode<TSESTree.TSTypeLiteral>, 'members'> {
|
|
852
|
+
members: TypeElement[];
|
|
853
|
+
}
|
|
854
|
+
interface TSTypeOperator extends Omit<AcornTSNode<TSESTree.TSTypeOperator>, 'typeAnnotation'> {
|
|
855
|
+
typeAnnotation: TypeNode | undefined;
|
|
856
|
+
}
|
|
857
|
+
interface TSTypeParameter
|
|
858
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeParameter>, 'name' | 'constraint' | 'default'> {
|
|
859
|
+
constraint: TypeNode | undefined;
|
|
860
|
+
default: TypeNode | undefined;
|
|
861
|
+
name: AST.Identifier;
|
|
862
|
+
}
|
|
863
|
+
interface TSTypeParameterDeclaration
|
|
864
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeParameterDeclaration>, 'params'> {
|
|
865
|
+
params: TypeNode[];
|
|
866
|
+
}
|
|
651
867
|
interface TSTypeParameterInstantiation
|
|
652
|
-
extends AcornTSNode<TSESTree.TSTypeParameterInstantiation> {
|
|
868
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeParameterInstantiation>, 'params'> {
|
|
869
|
+
params: TypeNode[];
|
|
870
|
+
}
|
|
653
871
|
interface TSTypePredicate extends AcornTSNode<TSESTree.TSTypePredicate> {}
|
|
654
|
-
interface TSTypeQuery
|
|
655
|
-
|
|
872
|
+
interface TSTypeQuery
|
|
873
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeQuery>, 'exprName' | 'typeArguments'> {
|
|
874
|
+
exprName: EntityName | TSImportType;
|
|
875
|
+
typeArguments: TSTypeParameterInstantiation | undefined;
|
|
876
|
+
}
|
|
877
|
+
interface TSTypeReference
|
|
878
|
+
extends Omit<AcornTSNode<TSESTree.TSTypeReference>, 'typeName' | 'typeArguments'> {
|
|
879
|
+
typeArguments: TSTypeParameterInstantiation | undefined;
|
|
880
|
+
typeName: EntityName;
|
|
881
|
+
}
|
|
656
882
|
interface TSUndefinedKeyword extends AcornTSNode<TSESTree.TSUndefinedKeyword> {}
|
|
657
|
-
interface TSUnionType extends AcornTSNode<TSESTree.TSUnionType> {
|
|
883
|
+
interface TSUnionType extends Omit<AcornTSNode<TSESTree.TSUnionType>, 'types'> {
|
|
884
|
+
types: TypeNode[];
|
|
885
|
+
}
|
|
886
|
+
// TSInterfaceHeritage doesn't exist in acorn-typescript which uses TSExpressionWithTypeArguments
|
|
887
|
+
interface TSInterfaceHeritage
|
|
888
|
+
extends Omit<AcornTSNode<TSESTree.TSInterfaceHeritage>, 'expression' | 'typeParameters'> {
|
|
889
|
+
expression: AST.Expression;
|
|
890
|
+
// acorn-typescript uses typeParameters instead of typeArguments
|
|
891
|
+
typeParameters: TSTypeParameterInstantiation | undefined;
|
|
892
|
+
}
|
|
893
|
+
// Extends TSInterfaceHeritage as it's the semantically the same as used by acorn-typescript
|
|
894
|
+
interface TSExpressionWithTypeArguments extends Omit<TSInterfaceHeritage, 'type'> {
|
|
895
|
+
type: 'TSExpressionWithTypeArguments';
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
interface TSClassImplements extends AcornTSNode<TSESTree.TSClassImplements> {}
|
|
658
899
|
interface TSUnknownKeyword extends AcornTSNode<TSESTree.TSUnknownKeyword> {}
|
|
659
900
|
interface TSVoidKeyword extends AcornTSNode<TSESTree.TSVoidKeyword> {}
|
|
901
|
+
interface NumberLiteral extends AcornTSNode<TSESTree.NumberLiteral> {}
|
|
902
|
+
interface StringLiteral extends AcornTSNode<TSESTree.StringLiteral> {}
|
|
660
903
|
|
|
661
904
|
// acorn-typescript specific nodes (not in @typescript-eslint/types)
|
|
662
905
|
interface TSParenthesizedType extends AST.BaseNode {
|
|
@@ -674,7 +917,6 @@ declare module 'estree' {
|
|
|
674
917
|
}
|
|
675
918
|
|
|
676
919
|
import type { Comment, Position } from 'acorn';
|
|
677
|
-
import type { M } from 'vitest/dist/chunks/environment.d.cL3nLXbE.js';
|
|
678
920
|
|
|
679
921
|
/**
|
|
680
922
|
* Parse error information
|
|
@@ -917,7 +1159,8 @@ export type Visitors<T extends AST.Node | AST.CSS.Node, U> = T['type'] extends '
|
|
|
917
1159
|
? never
|
|
918
1160
|
: SpecializedVisitors<T, U> & { _?: Visitor<T, U, T> };
|
|
919
1161
|
|
|
920
|
-
export interface Context<T, U>
|
|
1162
|
+
export interface Context<T, U>
|
|
1163
|
+
extends Omit<ESRap.Context, 'path' | 'state' | 'visit' | 'next' | 'stop'> {
|
|
921
1164
|
next: (state?: U) => T | void;
|
|
922
1165
|
path: T[];
|
|
923
1166
|
state: U;
|