Skip to content

Comments

Implement for-await (ES2018) transform, fix existing ES2018 issues#2861

Draft
jakebailey wants to merge 22 commits intojabaile/es2017from
jabaile/es2018
Draft

Implement for-await (ES2018) transform, fix existing ES2018 issues#2861
jakebailey wants to merge 22 commits intojabaile/es2017from
jabaile/es2018

Conversation

@jakebailey
Copy link
Member

@jakebailey jakebailey commented Feb 20, 2026

On top of #2853.

Basically the same caveats apply.

Also fixes other diffs that I noticed once the for-await was done.

const cache = Object.create(null);
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
})(name => super[name], (name, value) => super[name] = value);
- const _super = Object.create(null, {});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is actually unreferenced, so this is in a way an improvement.

func (node *ReturnStatement) computeSubtreeFacts() SubtreeFacts {
return propagateSubtreeFacts(node.Expression)
// return in an ES2018 async generator must be awaited
return propagateSubtreeFacts(node.Expression) | SubtreeContainsForAwaitOrAsyncGenerator
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shockingly:

    // @api
    function createReturnStatement(expression?: Expression): ReturnStatement {
        const node = createBaseNode<ReturnStatement>(SyntaxKind.ReturnStatement);
        node.expression = expression;
        // return in an ES2018 async generator must be awaited
        node.transformFlags |= propagateChildFlags(node.expression) |
            TransformFlags.ContainsES2018 |
            TransformFlags.ContainsHoistedDeclarationOrCompletion;

        node.jsDoc = undefined; // initialized by parser (JsDocContainer)
        node.flowNode = undefined; // initialized by binder (FlowContainer)
        return node;
    }

@jakebailey jakebailey changed the title Implement for-await (ES2018) transform Implement for-await (ES2018) transform, fix existing ES2018 issues Feb 20, 2026
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not new, but this is a bad emit bug itself somewhere

@jakebailey jakebailey force-pushed the jabaile/es2018 branch 9 times, most recently from 550880f to 57a50a6 Compare February 23, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant