@@ -262,14 +262,13 @@ function convertGenericsAttribute(script: SvelteScriptElement, ctx: Context) {
262
262
const { ast } = result ;
263
263
const statement = ast . body [ 0 ] as ESTree . ExpressionStatement ;
264
264
const rawExpression = statement . expression as ESTree . UnaryExpression ;
265
- const classDecl = rawExpression . argument as ESTree . FunctionExpression ;
266
- const typeParameters = ( classDecl as TSESTree . FunctionExpression )
265
+ const fnDecl = rawExpression . argument as ESTree . FunctionExpression ;
266
+ const typeParameters = ( fnDecl as TSESTree . FunctionExpression )
267
267
. typeParameters ! ;
268
268
const params = typeParameters . params ;
269
269
270
270
// Replace tokens
271
271
for ( const tokensKey of [ "tokens" , "comments" ] as const ) {
272
- const newTokens : any [ ] = [ ] ;
273
272
for ( const token of result . ast [ tokensKey ] ! ) {
274
273
if (
275
274
params . every (
@@ -278,13 +277,14 @@ function convertGenericsAttribute(script: SvelteScriptElement, ctx: Context) {
278
277
param . range [ 1 ] <= token . range [ 0 ] ,
279
278
)
280
279
) {
281
- newTokens . push ( token ) ;
280
+ ctx [ tokensKey ] . push ( token as any ) ;
282
281
}
283
282
}
284
- ctx [ tokensKey ] . push ( ...newTokens ) ;
285
283
}
286
284
287
285
for ( const param of params ) {
286
+ ( param as any ) . parent = generics ;
287
+ generics . params . push ( param ) ;
288
288
ctx . scriptLet . addGenericTypeAliasDeclaration (
289
289
param ,
290
290
( id , typeNode ) => {
@@ -297,7 +297,5 @@ function convertGenericsAttribute(script: SvelteScriptElement, ctx: Context) {
297
297
param . default = typeNode ;
298
298
} ,
299
299
) ;
300
- ( param as any ) . parent = generics ;
301
- generics . params . push ( param ) ;
302
300
}
303
301
}
0 commit comments