Fix self tail call return type inference in assigned anonymous functions (#58124)

This commit is contained in:
Andrew Branch
2024-04-10 12:51:34 -07:00
committed by GitHub
parent 30095a225c
commit 2b038ff64a
9 changed files with 214 additions and 11 deletions

View File

@@ -28086,7 +28086,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
case SyntaxKind.Identifier:
if (!isThisInTypeQuery(node)) {
const symbol = getResolvedSymbol(node as Identifier);
return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
return isConstantVariable(symbol)
|| isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol)
|| !!symbol.valueDeclaration && isFunctionExpression(symbol.valueDeclaration);
}
break;
case SyntaxKind.PropertyAccessExpression:
@@ -37796,7 +37798,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (
expr.kind === SyntaxKind.CallExpression &&
(expr as CallExpression).expression.kind === SyntaxKind.Identifier &&
checkExpressionCached((expr as CallExpression).expression).symbol === func.symbol
checkExpressionCached((expr as CallExpression).expression).symbol === getMergedSymbol(func.symbol) &&
(!isFunctionExpressionOrArrowFunction(func.symbol.valueDeclaration!) || isConstantReference((expr as CallExpression).expression))
) {
hasReturnOfTypeNever = true;
return;