Skip to content

Comments

Implement ES2017 (async) transforms#2853

Open
jakebailey wants to merge 32 commits intomainfrom
jabaile/es2017
Open

Implement ES2017 (async) transforms#2853
jakebailey wants to merge 32 commits intomainfrom
jabaile/es2017

Conversation

@jakebailey
Copy link
Member

This is just one transform. It's pretty much a pure port, with some differences:

  • arguments capturing is not done via NodeCheck flags. While declared, the checker does not currently set them, and it's possible to get this info without requiring checking. I think this is a net improvement.
  • super detection is similarly changed, but also handles rewriting directly rather than relying on emit hooks.
  • Since we do not support ES5, we unconditionally use the real Promise constructor.

All diffs related to this get deleted (yay), except the ones that are still missing the ES2018 transform for async-for.

Copilot AI review requested due to automatic review settings February 20, 2026 17:46
@jakebailey jakebailey changed the title Implenent ES2017 (async) transforms Implement ES2017 (async) transforms Feb 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements the ES2017 async/await transform, converting async functions and arrow functions to use generator-based __awaiter helpers when targeting ES2015 or earlier. The implementation is a pure port from the TypeScript reference implementation with improvements to arguments and super handling.

Changes:

  • Async functions are transformed to regular functions returning __awaiter() calls with generator functions
  • await expressions are converted to yield expressions within the generator
  • Improved handling of arguments capturing and super property access without relying on checker flags

Reviewed changes

Copilot reviewed 299 out of 445 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testdata/baselines/reference/submodule/**/*.diff Deleted diffs showing convergence with TypeScript output for async transforms
testdata/baselines/reference/submodule/**/*.js Updated baselines showing async functions now emit __awaiter helper calls
internal/printer/helpers.go Added __awaiter, AsyncSuperHelper, and AdvancedAsyncSuperHelper emit helpers
internal/printer/printer.go Fixed binary expression precedence for yield in assignments
internal/printer/emitflags.go Added EFAsyncFunctionBody and EFNoSubstitution flags
internal/printer/emitresolver.go Added IsArgumentsLocalBinding method for arguments detection
internal/checker/emitresolver.go Implemented IsArgumentsLocalBinding to check if identifier refers to arguments
internal/checker/types.go Removed unused NodeCheckFlags for async super and arguments
internal/checker/checker.go Removed commented code for async super property checks
internal/transformers/tstransforms/utilities.go Removed convertEntityNameToExpression (moved to factory)
internal/transformers/tstransforms/runtimesyntax.go Updated to use factory method for entity name conversion
internal/transformers/jsxtransforms/utilities.go Deleted file (functionality moved to factory)
internal/transformers/jsxtransforms/jsx.go Updated to use factory method for entity name conversion

@jakebailey jakebailey requested a review from weswigham February 20, 2026 17:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 299 out of 488 changed files in this pull request and generated 3 comments.

Comment on lines +179 to +181
printer.makeFileLevelOptimisticUniqueName = func(name string) string {
return printer.nameGenerator.MakeFileLevelOptimisticUniqueName(name)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this not just

Suggested change
printer.makeFileLevelOptimisticUniqueName = func(name string) string {
return printer.nameGenerator.MakeFileLevelOptimisticUniqueName(name)
}
printer.makeFileLevelOptimisticUniqueName = printer.nameGenerator.MakeFileLevelOptimisticUniqueName

?

But moreover, why is it not just a method on printer?

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.

3 participants