Skip to content

Fix async arrow this capture in static field emit#4103

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-async-arrow-issue
Draft

Fix async arrow this capture in static field emit#4103
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-async-arrow-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

Downleveled async arrows in static field initializers captured ambient this instead of the class constructor. This produced incorrect __awaiter(this, ...) emit when the initializer was moved outside the class body.

  • Emit behavior

    • Mark async arrows inside static field/static block initializers with the class constructor capture.
    • Use that captured class reference as the __awaiter thisArg.
  • Regression coverage

    • Added a compiler test for a namespace-wrapped static async arrow initializer.
    • Updated related async-arrow-in-class baselines.
namespace NS {
  export class C {
    static h = async () => 1;
  }
}

Now downlevels to:

var _a;
class C {
}
_a = C;
C.h = () => __awaiter(_a, void 0, void 0, function* () { return 1; });

Copilot AI and others added 2 commits May 30, 2026 16:31
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix async arrow in static field initializer to capture correct this Fix async arrow this capture in static field emit May 30, 2026
Copilot AI requested a review from jakebailey May 30, 2026 16:53
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.

Downleveled async arrow in a static field initializer captures the wrong this

2 participants