@@ -28295,14 +28295,16 @@ namespace ts {
28295
28295
returnType = getUnionType(types, UnionReduction.Subtype);
28296
28296
}
28297
28297
28298
+ const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
28298
28299
if (returnType || yieldType || nextType) {
28299
- if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield);
28300
- if (returnType) reportErrorsFromWidening(func, returnType, WideningKind.FunctionReturn);
28301
- if (nextType) reportErrorsFromWidening(func, nextType, WideningKind.GeneratorNext);
28300
+ if (!contextualSignature) {
28301
+ if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield);
28302
+ if (returnType) reportErrorsFromWidening(func, returnType, WideningKind.FunctionReturn);
28303
+ if (nextType) reportErrorsFromWidening(func, nextType, WideningKind.GeneratorNext);
28304
+ }
28302
28305
if (returnType && isUnitType(returnType) ||
28303
28306
yieldType && isUnitType(yieldType) ||
28304
28307
nextType && isUnitType(nextType)) {
28305
- const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
28306
28308
const contextualType = !contextualSignature ? undefined :
28307
28309
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
28308
28310
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
@@ -28316,9 +28318,11 @@ namespace ts {
28316
28318
}
28317
28319
}
28318
28320
28319
- if (yieldType) yieldType = getWidenedType(yieldType);
28320
- if (returnType) returnType = getWidenedType(returnType);
28321
- if (nextType) nextType = getWidenedType(nextType);
28321
+ if (!contextualSignature) {
28322
+ if (yieldType) yieldType = getWidenedType(yieldType);
28323
+ if (returnType) returnType = getWidenedType(returnType);
28324
+ if (nextType) nextType = getWidenedType(nextType);
28325
+ }
28322
28326
}
28323
28327
28324
28328
if (isGenerator) {
0 commit comments