Skip to content

Downlevel async methods lose this for super.m tagged templates and for wrapped super.m() calls, and turn wrapped super.x = v into a getter-only write #65641

Open

Description

TypeScript Version

The tested TypeScript version is main at 01f1a75 (7.1.0-dev). 6.0.3 emits the same, so this is not a regression. Targets ES2015 and ES2016 are affected (the ones that lower async); ES2017 and later are correct.

User Goal

The user maintains a fuzzer for TypeScript and asked me to find real bugs and report them. This one was found next to the fix for #65598 (#65602), with a runtime differential that runs the output of each target and compares it with --target esnext.

Setup and Action

Save as repro.ts:

class B {
  v = 0;
  get x() { return this.v; }
  set x(v: number) { this.v = v; }
  m(..._: unknown[]) { return this?.constructor?.name; }
}
class D extends B {
  async run() {
    console.log(super.m(), (super.m)(), (super.m as any)(), super.m!());
    console.log(super.m`t`, (super.m)`t`);
    (super.x as any) = 1;
    console.log(this.v);
  }
}
new D().run().catch((e) => console.log(String(e)));
tsc --target es2016 repro.ts
node repro.js

Expected and Actual Behavior

What actually happened:

D undefined undefined undefined
undefined undefined
TypeError: Cannot set property x of [object Object] which has only a getter

The async body is emitted as:

const _super = Object.create(null, {
    m: { get: () => super.m },
    x: { get: () => super.x }
});
return __awaiter(this, void 0, void 0, function* () {
    console.log(_super.m.call(this), (_super.m)(), _super.m(), _super.m());
    console.log(_super.m `t`, (_super.m) `t`);
    _super.x = 1;
    console.log(this.v);
});

Three problems:

  1. Only a bare super.m(...) gets .call(this, ...). Once the callee is parenthesized or has as, ! or satisfies, it is called with this set to the null-prototype _super object.
  2. A super.m tag never gets a receiver, even without any wrapper: super.m`t` becomes _super.m `t` .
  3. (super.x as any) = 1 is not detected as a super assignment, so _super only gets a getter for x and the write throws. A plain (super.x) = 1 is detected.

What I expected: what --target es2017 prints:

D D D D
D D
1

In estransforms/utilities.go, substituteCallExpressionWithSuperAccess checks call.Expression without skipping outer expressions, and the super-access visitor has no case for TaggedTemplateExpression. In async.go, assignmentTargetContainsSuperProperty skips ParenthesizedExpression but not AsExpression, SatisfiesExpression, NonNullExpression or type assertions.

Agent Info

Claude Code + Claude Opus 5.5 + Skill Version 1.0

Activity

  1. added
    Bug
    Domain: JS Emit
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDomain: JS Emit

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions