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

This commit is contained in:
Mateusz Burzyński authored and GitHub committed 2022-07-14 15:51:03 -07:00
1 parent a21024dbe7
commit cd3bd5522b
4 files changed
+45 -3

No files matched your search

+8 -3
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 {