Skip to content
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

Not transforming super in async arrow function in class static property #8326

Open
overlookmotel opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Comments

@overlookmotel
Copy link
Contributor

overlookmotel commented Jan 7, 2025

Input:

class C {
  static fn = async () => super.staticProp;
}

Output:

class C {}
_defineProperty(C, "fn", babelHelpers.asyncToGenerator(function* () {
    // `super` isn't valid here. Oops!
    return super.staticProp;
}));

Playground

If the arrow function isn't async it works correctly. Playground

Looks like class properties and async-to-generator transforms aren't interacting with each other correctly. Probably the fault is in class properties transform. It should have replaced super.staticProp before async-to-generator transform gets to it.

@overlookmotel overlookmotel added C-bug Category - Bug A-transformer Area - Transformer / Transpiler labels Jan 7, 2025
@Dunqing
Copy link
Member

Dunqing commented Jan 8, 2025

Another way is to allow StaticVisitor to transform the function's super, now restricted to this_depth == 0

// `super.prop`
Expression::StaticMemberExpression(_) if self.this_depth == 0 => {
self.super_converter.transform_static_member_expression(expr, self.ctx);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler C-bug Category - Bug
Projects
None yet
Development

No branches or pull requests

2 participants