@@ -9184,13 +9184,14 @@ namespace ts {
9184
9184
}
9185
9185
}
9186
9186
9187
- function createInferenceContext(signature: Signature, inferUnionTypes: boolean): InferenceContext {
9187
+ function createInferenceContext(signature: Signature, inferUnionTypes: boolean, useAnyForNoInferences: boolean ): InferenceContext {
9188
9188
const inferences = map(signature.typeParameters, createTypeInferencesObject);
9189
9189
return {
9190
9190
signature,
9191
9191
inferUnionTypes,
9192
9192
inferences,
9193
9193
inferredTypes: new Array(signature.typeParameters.length),
9194
+ useAnyForNoInferences
9194
9195
};
9195
9196
}
9196
9197
@@ -9604,7 +9605,7 @@ namespace ts {
9604
9605
getInferenceMapper(context)));
9605
9606
}
9606
9607
else {
9607
- inferredType = emptyObjectType;
9608
+ inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType;
9608
9609
}
9609
9610
9610
9611
inferenceSucceeded = true;
@@ -13652,7 +13653,7 @@ namespace ts {
13652
13653
13653
13654
// Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec)
13654
13655
function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper: TypeMapper): Signature {
13655
- const context = createInferenceContext(signature, /*inferUnionTypes*/ true);
13656
+ const context = createInferenceContext(signature, /*inferUnionTypes*/ true, /*useAnyForNoInferences*/ false );
13656
13657
forEachMatchingParameterType(contextualSignature, signature, (source, target) => {
13657
13658
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
13658
13659
inferTypesWithContext(context, instantiateType(source, contextualMapper), target);
@@ -14353,7 +14354,7 @@ namespace ts {
14353
14354
let candidate: Signature;
14354
14355
let typeArgumentsAreValid: boolean;
14355
14356
const inferenceContext = originalCandidate.typeParameters
14356
- ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false)
14357
+ ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ isInJavaScriptFile(node) )
14357
14358
: undefined;
14358
14359
14359
14360
while (true) {
0 commit comments