@@ -767,8 +767,8 @@ namespace ts.codefix {
767
767
return inferences . filter ( i => toRemove . every ( f => ! f ( i ) ) ) ;
768
768
}
769
769
770
- function unifyTypes ( inferences : ReadonlyArray < Type > , fallback = checker . getAnyType ( ) ) : Type {
771
- if ( ! inferences . length ) return fallback ;
770
+ function unifyTypes ( inferences : ReadonlyArray < Type > ) : Type {
771
+ if ( ! inferences . length ) return checker . getAnyType ( ) ;
772
772
773
773
// 1. string or number individually override string | number
774
774
// 2. non-any, non-void overrides any or void
@@ -874,11 +874,11 @@ namespace ts.codefix {
874
874
}
875
875
876
876
if ( usage . calls ) {
877
- callSignatures . push ( getSignatureFromCalls ( usage . calls , checker . getAnyType ( ) ) ) ;
877
+ callSignatures . push ( getSignatureFromCalls ( usage . calls ) ) ;
878
878
}
879
879
880
880
if ( usage . constructs ) {
881
- constructSignatures . push ( getSignatureFromCalls ( usage . constructs , checker . getAnyType ( ) ) ) ;
881
+ constructSignatures . push ( getSignatureFromCalls ( usage . constructs ) ) ;
882
882
}
883
883
884
884
if ( usage . stringIndex ) {
@@ -1047,10 +1047,10 @@ namespace ts.codefix {
1047
1047
}
1048
1048
1049
1049
function getFunctionFromCalls ( calls : CallUsage [ ] ) {
1050
- return checker . createAnonymousType ( undefined ! , createSymbolTable ( ) , [ getSignatureFromCalls ( calls , checker . getAnyType ( ) ) ] , emptyArray , undefined , undefined ) ;
1050
+ return checker . createAnonymousType ( undefined ! , createSymbolTable ( ) , [ getSignatureFromCalls ( calls ) ] , emptyArray , undefined , undefined ) ;
1051
1051
}
1052
1052
1053
- function getSignatureFromCalls ( calls : CallUsage [ ] , fallbackReturn : Type ) : Signature {
1053
+ function getSignatureFromCalls ( calls : CallUsage [ ] ) : Signature {
1054
1054
const parameters : Symbol [ ] = [ ] ;
1055
1055
const length = Math . max ( ...calls . map ( c => c . argumentTypes . length ) ) ;
1056
1056
for ( let i = 0 ; i < length ; i ++ ) {
@@ -1061,7 +1061,7 @@ namespace ts.codefix {
1061
1061
}
1062
1062
parameters . push ( symbol ) ;
1063
1063
}
1064
- const returnType = unifyTypes ( inferFromUsage ( combineUsages ( calls . map ( call => call . return_ ) ) ) , fallbackReturn ) ;
1064
+ const returnType = unifyTypes ( inferFromUsage ( combineUsages ( calls . map ( call => call . return_ ) ) ) ) ;
1065
1065
// TODO: GH#18217
1066
1066
return checker . createSignature ( /*declaration*/ undefined ! , /*typeParameters*/ undefined , /*thisParameter*/ undefined , parameters , returnType , /*typePredicate*/ undefined , length , /*hasRestParameter*/ false , /*hasLiteralTypes*/ false ) ;
1067
1067
}
0 commit comments