Yield return type should be defined by the next argument type in generators #32995
Closed
5 tasks done
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Search Terms
Suggestion
The 3.6RC is implementing stricter generator type. This is a good first step to model ES6 generators by allowing the definition of both yielded and returned values.
There was a long discussion about this implementation in issue #2983. It has been closed but a use case is still not covered : the async runners like co or redux-saga (or any other lib using generators as co-routines).
In my humble opinion, the last comment about it (#2983 (comment)) is a good starting point. At least, it allows to strictly type a runner implementing async/await behavior.
Examples
There is lot of examples out there since co-routines is a pattern gaining lots of popularity. Even in large application, being able to hook
await
can be very useful (for cancellation or execution context).Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: