@@ -376,6 +376,7 @@ namespace ts.codefix {
376
376
let maxArgsSignature = signatures [ 0 ] ;
377
377
let minArgumentCount = signatures [ 0 ] . minArgumentCount ;
378
378
let someSigHasRestParameter = false ;
379
+ let maxTypeArgsSignature = signatures [ 0 ] ;
379
380
for ( const sig of signatures ) {
380
381
minArgumentCount = Math . min ( sig . minArgumentCount , minArgumentCount ) ;
381
382
if ( signatureHasRestParameter ( sig ) ) {
@@ -384,6 +385,9 @@ namespace ts.codefix {
384
385
if ( sig . parameters . length >= maxArgsSignature . parameters . length && ( ! signatureHasRestParameter ( sig ) || signatureHasRestParameter ( maxArgsSignature ) ) ) {
385
386
maxArgsSignature = sig ;
386
387
}
388
+ if ( sig . typeParameters && ( ! maxTypeArgsSignature . typeParameters || sig . typeParameters . length > maxTypeArgsSignature . typeParameters . length ) ) {
389
+ maxTypeArgsSignature = sig ;
390
+ }
387
391
}
388
392
const maxNonRestArgs = maxArgsSignature . parameters . length - ( signatureHasRestParameter ( maxArgsSignature ) ? 1 : 0 ) ;
389
393
const maxArgsParameterSymbolNames = maxArgsSignature . parameters . map ( symbol => symbol . name ) ;
@@ -402,11 +406,14 @@ namespace ts.codefix {
402
406
parameters . push ( restParameter ) ;
403
407
}
404
408
409
+ const typeParameters = maxTypeArgsSignature . typeParameters ?. map ( typeParam =>
410
+ factory . createTypeParameterDeclaration ( typeParam . symbol . getName ( ) ) ) ;
411
+
405
412
return createStubbedMethod (
406
413
modifiers ,
407
414
name ,
408
415
optional ,
409
- /* typeParameters*/ undefined ,
416
+ typeParameters ,
410
417
parameters ,
411
418
getReturnTypeFromSignatures ( signatures , checker , context , enclosingDeclaration ) ,
412
419
quotePreference ,
0 commit comments