mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 16:56:06 -05:00
Fixed false positive circular errors for await expressions with simple non-generic calls in CFA loops (#51126)
This commit is contained in:
committed by
GitHub
parent
00567618bd
commit
2c1fda249f
@@ -427,6 +427,7 @@ import {
|
||||
isAssignmentTarget,
|
||||
isAsyncFunction,
|
||||
isAutoAccessorPropertyDeclaration,
|
||||
isAwaitExpression,
|
||||
isBinaryExpression,
|
||||
isBindableObjectDefinePropertyCall,
|
||||
isBindableStaticElementAccessExpression,
|
||||
@@ -36482,7 +36483,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return type;
|
||||
}
|
||||
|
||||
function getQuickTypeOfExpression(node: Expression) {
|
||||
function getQuickTypeOfExpression(node: Expression): Type | undefined {
|
||||
let expr = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
|
||||
if (isJSDocTypeAssertion(expr)) {
|
||||
const type = getJSDocTypeAssertionType(expr);
|
||||
@@ -36491,14 +36492,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
expr = skipParentheses(node);
|
||||
if (isAwaitExpression(expr)) {
|
||||
const type = getQuickTypeOfExpression(expr.expression);
|
||||
return type ? getAwaitedType(type) : undefined;
|
||||
}
|
||||
// Optimize for the common case of a call to a function with a single non-generic call
|
||||
// signature where we can just fetch the return type without checking the arguments.
|
||||
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
|
||||
const type = isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
||||
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
||||
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
|
||||
return getTypeFromTypeNode((expr as TypeAssertion).type);
|
||||
|
||||
Reference in New Issue
Block a user