Skip to content

Commit ef1b23b

Browse files
committed
Use the return type as inference location
1 parent 69b2e7c commit ef1b23b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/compiler/checker.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14894,6 +14894,20 @@ namespace ts {
1489414894
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
1489514895
inferTypes(context.inferences, instantiateType(source, contextualMapper), target);
1489614896
});
14897+
// If contextualMapper is fakeInferenceMapper we are being called by checkApplicableSignature.
14898+
if (contextualMapper === fakeInferenceMapper) {
14899+
let source, target;
14900+
if (contextualSignature.typePredicate && signature.typePredicate && contextualSignature.typePredicate.kind === signature.typePredicate.kind) {
14901+
source = contextualSignature.typePredicate.type;
14902+
target = signature.typePredicate.type;
14903+
}
14904+
else {
14905+
source = getReturnTypeOfSignature(contextualSignature);
14906+
target = getReturnTypeOfSignature(signature);
14907+
}
14908+
// source is already instantiated by the caller of fakeInferenceMapper.
14909+
inferTypes(context.inferences, source, target);
14910+
}
1489714911
const inferred = getInferredTypes(context);
1489814912
for (let i = 0; i < inferred.length; ++i) {
1489914913
// If inference has failed, use the first constituent type. During checking, the other

0 commit comments

Comments
 (0)