Skip to content

Commit dacc851

Browse files
committed
No contextual return type when type is circular
1 parent a6a27ab commit dacc851

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6576,6 +6576,10 @@ namespace ts {
65766576
return signature.resolvedReturnType;
65776577
}
65786578

6579+
function isResolvingReturnTypeOfSignature(signature: Signature) {
6580+
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, TypeSystemPropertyName.ResolvedReturnType) >= 0;
6581+
}
6582+
65796583
function getRestTypeOfSignature(signature: Signature): Type {
65806584
if (signature.hasRestParameter) {
65816585
const type = getTypeOfSymbol(lastOrUndefined(signature.parameters));
@@ -12949,7 +12953,7 @@ namespace ts {
1294912953
// Otherwise, if the containing function is contextually typed by a function type with exactly one call signature
1295012954
// and that call signature is non-generic, return statements are contextually typed by the return type of the signature
1295112955
const signature = getContextualSignatureForFunctionLikeDeclaration(<FunctionExpression>functionDecl);
12952-
if (signature) {
12956+
if (signature && !isResolvingReturnTypeOfSignature(signature)) {
1295312957
return getReturnTypeOfSignature(signature);
1295412958
}
1295512959

0 commit comments

Comments
 (0)