ES2017 Async Generator Suspended on yield*
Continues Execution When Returned
#61022
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
π Search Terms
es2017 async generator delegator await loop yield*
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?declaration=false&module=0&ts=5.8.0-dev.20250122#code/PQgEB4CcFMDNpgOwMbVAGwJYCMC8AiaAZ0WgA8AXfUYAPgCh6AKAQyIE8VQmBKUXWqADe9UGJrBQAQQAmLAA4VoM0LEgB7ALYAuUeLAALChXlFtIAO5WAdBXbziySJkXoWiAObX1kD8BnqyETABu4y2OrqANbAMOjQbNAAtIjqSsF2DkROLhRJAExJAMzWRproemJsnMiqAK4oFJjqiABUoB68wpXiYuyY0Ogy7awcXLANyE0tI3wivQvi-YMqAIwA3D29AL48vJtb4sgtROrx1ujqnfgssEqQ+DybO4y9x4hEFKCYX7gdvABtADK7E0EXQ1mqKAAkvcWBQfABdfY9d6nc6XTosCwsH7fCjWUiUXhPHrY3FfH7WGAUOqQRAAfmsKN2KKAA
π» Code
π Actual behavior
If you run the provided TS code directly in a modern Node process, you get the expected following output:
If you instead run the JS output code, you get:
Here, the downleveled code behaves differently than the source and continues execution after
.return()
was called in the iterator.π Expected behavior
The generated code should work like the original.
Additional information about the issue
This only seems to be an issue when
yield*
ing values from another generator. The following works just fine:If you extract the generator into a constant and put the log in a while loop, the loop never exits:
If you inline the generator from the above example, the "after" is still logged, but the loop isn't run. Only if you extract the inline generator into a separate constant and only yield that within the loop instead, it keeps going.
The above does not apply to generators that only
yield*
themselves:The text was updated successfully, but these errors were encountered: