diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c161dd3f065..6a4891597b9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9598,7 +9598,7 @@ namespace ts { getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; @@ -9614,9 +9614,6 @@ namespace ts { context.inferredTypes[index] = inferredType = instantiatedConstraint; } } - if (context.useAnyForNoInferences && !inferences.length && inferredType === emptyObjectType) { - context.inferredTypes[index] = inferredType = anyType; - } } else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) { // If inference failed, it is necessary to record the index of the failed type parameter (the one we are on).