Skip to content

Commit e0599fd

Browse files
committed
Instantiate contextual type for return type in getReturnTypeFromBody
1 parent 60a1b1d commit e0599fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19051,7 +19051,7 @@ namespace ts {
1905119051

1905219052
// If the given contextual type contains instantiable types and if a mapper representing
1905319053
// return type inferences is available, instantiate those types using that mapper.
19054-
function instantiateContextualType(contextualType: Type | undefined, node: Expression, contextFlags?: ContextFlags): Type | undefined {
19054+
function instantiateContextualType(contextualType: Type | undefined, node: Node, contextFlags?: ContextFlags): Type | undefined {
1905519055
if (contextualType && maybeTypeOfKind(contextualType, TypeFlags.Instantiable)) {
1905619056
const inferenceContext = getInferenceContext(node);
1905719057
// If no inferences have been made, nothing is gained from instantiating as type parameters
@@ -23363,7 +23363,7 @@ namespace ts {
2336323363
nextType && isUnitType(nextType)) {
2336423364
const contextualType = !contextualSignature ? undefined :
2336523365
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
23366-
getReturnTypeOfSignature(contextualSignature);
23366+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
2336723367
if (isGenerator) {
2336823368
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, IterationTypeKind.Yield, isAsync);
2336923369
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, IterationTypeKind.Return, isAsync);

0 commit comments

Comments
 (0)