@@ -14964,11 +14964,10 @@ namespace ts {
14964
14964
}
14965
14965
else {
14966
14966
let yieldTypes: Type[];
14967
- let returnTypes : Type[];
14967
+ let types : Type[];
14968
14968
if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function
14969
- yieldTypes = checkAndAggregateYieldOperandTypes(func, contextualMapper);
14970
- returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
14971
- if (yieldTypes.length === 0 && (!returnTypes || returnTypes.length === 0)) {
14969
+ types = concatenate(checkAndAggregateYieldOperandTypes(func, contextualMapper), checkAndAggregateReturnExpressionTypes(func, contextualMapper));
14970
+ if (!types || types.length === 0) {
14972
14971
const iterableIteratorAny = functionFlags & FunctionFlags.Async
14973
14972
? createAsyncIterableIteratorType(anyType) // AsyncGenerator function
14974
14973
: createIterableIteratorType(anyType); // Generator function
@@ -14980,22 +14979,22 @@ namespace ts {
14980
14979
}
14981
14980
}
14982
14981
else {
14983
- returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
14984
- if (!returnTypes ) {
14982
+ types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
14983
+ if (!types ) {
14985
14984
// For an async function, the return type will not be never, but rather a Promise for never.
14986
14985
return functionFlags & FunctionFlags.Async
14987
14986
? createPromiseReturnType(func, neverType) // Async function
14988
14987
: neverType; // Normal function
14989
14988
}
14990
- if (returnTypes .length === 0) {
14989
+ if (types .length === 0) {
14991
14990
// For an async function, the return type will not be void, but rather a Promise for void.
14992
14991
return functionFlags & FunctionFlags.Async
14993
14992
? createPromiseReturnType(func, voidType) // Async function
14994
14993
: voidType; // Normal function
14995
14994
}
14996
14995
}
14997
14996
// Return a union of the return expression types.
14998
- type = getUnionType(yieldTypes ? yieldTypes.concat(returnTypes ) : returnTypes , /*subtypeReduction*/ true);
14997
+ type = getUnionType(yieldTypes ? yieldTypes.concat(types ) : types , /*subtypeReduction*/ true);
14999
14998
15000
14999
if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function
15001
15000
type = functionFlags & FunctionFlags.Async
0 commit comments