Fixed an issue with generic naked T not being allowed as async generator's return (#49023)

This commit is contained in:
Mateusz Burzyński
2022-07-15 00:51:03 +02:00
committed by GitHub
parent a21024dbe7
commit cd3bd5522b
4 changed files with 45 additions and 3 deletions

View File

@@ -39273,9 +39273,14 @@ namespace ts {
function unwrapReturnType(returnType: Type, functionFlags: FunctionFlags) {
const isGenerator = !!(functionFlags & FunctionFlags.Generator);
const isAsync = !!(functionFlags & FunctionFlags.Async);
return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Return, returnType, isAsync) || errorType :
isAsync ? getAwaitedTypeNoAlias(returnType) || errorType :
returnType;
if (isGenerator) {
const returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Return, returnType, isAsync);
if (!returnIterationType) {
return errorType;
}
return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType;
}
return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
}
function isUnwrappedReturnTypeVoidOrAny(func: SignatureDeclaration, returnType: Type): boolean {