-
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
Constrain return statements in generator functions. #18726
Comments
@mhegazy @RyanCavanaugh @rbuckton can you please take a look at #23571? |
I think generator function's return type is not constrained by iterator type. At least that return type can be |
I do not think this is the correct solution to this issues. the underlying issue here is that the generator has two possible return states, and each has a possibly different type. each type is witnessed in different use case ( #11375 tracks correctly modelling the generator interface and correctly inferring the the three type, 1. yielded values, 2, returned values, and 3. yield expression type (input to |
closing in favor of #11375. |
Generator functions should constrain their return types to match the result type of the return method on their declared Iterator subtype.
This is deeply related to #2983 - but I wanted to call it out separately because it's a small subset of the total changes required to completely support iterators as coroutines.
TypeScript Version: 2.5.2
Code
The text was updated successfully, but these errors were encountered: