-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat 'yield;' as 'yield undefined;' #22297
Conversation
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts (1 errors) ==== | ||
function* g() { | ||
~ | ||
!!! error TS7025: Generator implicitly has type 'IterableIterator<any>' because it does not yield any values. Consider supplying a return type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the correct error. without noImplicitAny, it should be an implicit any and not undefined
.
src/compiler/checker.ts
Outdated
return aggregatedTypes; | ||
} | ||
|
||
function getYieldedTypeOfYieldExpression(node: YieldExpression, isAsync: boolean, checkMode?: CheckMode): Type { | ||
const errorNode = node.expression || node; | ||
const expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the refactoring that is part of this PR -- it make the code much easier to read. But I want to point out that this is the only line needed to fix the bug. The bug would get fixed a lot faster if we could just review a one-line fix and look at the refactor separately.
Fixes #22290
Previously we would skip over
yield;
with no argument; now we will treat it as yieldingundefined
.