@@ -9184,13 +9184,14 @@ namespace ts {
91849184 }
91859185 }
91869186
9187- function createInferenceContext(signature: Signature, inferUnionTypes: boolean): InferenceContext {
9187+ function createInferenceContext(signature: Signature, inferUnionTypes: boolean, useAnyForNoInferences: boolean ): InferenceContext {
91889188 const inferences = map(signature.typeParameters, createTypeInferencesObject);
91899189 return {
91909190 signature,
91919191 inferUnionTypes,
91929192 inferences,
91939193 inferredTypes: new Array(signature.typeParameters.length),
9194+ useAnyForNoInferences
91949195 };
91959196 }
91969197
@@ -9604,7 +9605,7 @@ namespace ts {
96049605 getInferenceMapper(context)));
96059606 }
96069607 else {
9607- inferredType = emptyObjectType;
9608+ inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType;
96089609 }
96099610
96109611 inferenceSucceeded = true;
@@ -13652,7 +13653,7 @@ namespace ts {
1365213653
1365313654 // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec)
1365413655 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 );
1365613657 forEachMatchingParameterType(contextualSignature, signature, (source, target) => {
1365713658 // Type parameters from outer context referenced by source type are fixed by instantiation of the source type
1365813659 inferTypesWithContext(context, instantiateType(source, contextualMapper), target);
@@ -14353,7 +14354,7 @@ namespace ts {
1435314354 let candidate: Signature;
1435414355 let typeArgumentsAreValid: boolean;
1435514356 const inferenceContext = originalCandidate.typeParameters
14356- ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false)
14357+ ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ isInJavaScriptFile(node) )
1435714358 : undefined;
1435814359
1435914360 while (true) {
0 commit comments