Skip to content

Add esnext transform #819

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

Merged
merged 5 commits into from
Apr 24, 2025
Merged

Add esnext transform #819

merged 5 commits into from
Apr 24, 2025

Conversation

rbuckton
Copy link
Member

This adds the ESNext transform, which handles the downlevel transformation of using and await using declarations.

This PR is dependent on #815, so most feedback related to ast/ast.go, printer/emitcontext.go, and printer/factory.go should be addressed there.

@Copilot Copilot AI review requested due to automatic review settings April 23, 2025 14:41
Copy link
Contributor

@Copilot 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 adds support for the ESNext transform to downlevel ‘using’ and ‘await using’ declarations by modifying the transformation and printer layers, among other updates. Key changes include renaming module IIFE parameters in baseline tests, updating various helper and AST transformation functions from binary expressions to assignment expressions, and revising name generation and helper functions in the printer.

Reviewed Changes

Copilot reviewed 460 out of 461 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testdata/baselines/reference/submodule/compiler/collisionCodeGenModuleWithConstructorChildren.js Renames IIFE parameter from M_1 to M_2 to avoid conflicts
testdata/baselines/reference/submodule/compiler/collisionCodeGenModuleWithAccessorChildren.js Consistent renaming of IIFE parameters to M_2 and M_3
internal/transformers/*.go Updates transformation logic (e.g. replacing NewBinaryExpression with NewAssignmentExpression) to support ESNext syntax
internal/printer/* Adjustments in name generation and helper invocations including updates in test expectations
internal/ast/utilities.go Added a new helper (RangeIsSynthesized) for synthetic position checking
Files not reviewed (1)
  • testdata/baselines/reference/submodule/compiler/collisionCodeGenModuleWithAccessorChildren.js.diff: Language not supported
Comments suppressed due to low confidence (2)

internal/printer/namegenerator_test.go:208

  • [nitpick] The test currently expects "foo_2" for a unique name in a scoped context, although the comment indicates that "foo_1" may be more appropriate. Please verify and update the expected behavior in line with the intended scoping rules once the port is complete.
assert.Equal(t, "foo_2", g.GenerateName(name2)) // Matches Strada, but is incorrect

internal/printer/namegenerator.go:106

  • [nitpick] This comment indicates that the generated names are currently being added to a global set rather than being scoped per the current nameGenerationScope. Consider revising this logic so that generated names are tracked per scope if that behavior is the intended design.
g.generatedNames.Add(name) // NOTE: Matches Strada, but is incorrect.

Verified

This commit was signed with the committer’s verified signature.
rbuckton Ron Buckton

Verified

This commit was signed with the committer’s verified signature.
rbuckton Ron Buckton

Verified

This commit was signed with the committer’s verified signature.
rbuckton Ron Buckton

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
rbuckton Ron Buckton
@rbuckton rbuckton added this pull request to the merge queue Apr 24, 2025
Merged via the queue into microsoft:main with commit 9e35174 Apr 24, 2025
23 checks passed
@rbuckton rbuckton deleted the esnext branch April 24, 2025 23:08
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.

None yet

4 participants