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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect computed key evaluation order when a class has only class decorators #16341

Closed
1 task done
JLHwung opened this issue Mar 12, 2024 · 1 comment 路 Fixed by #16350
Closed
1 task done

Comments

@JLHwung
Copy link
Contributor

JLHwung commented Mar 12, 2024

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const dummy = () => {}

const logs = [];

@dummy
class C {
  [(logs.push(1), 1)];
  static [(logs.push(2), 2)];
  [(logs.push(3), 3)];
}

console.log(logs);

REPL

Configuration file name

No response

Configuration

{
  "plugins": [
    ["proposal-decorators", { "version": "2023-11" }]
  ]
}

Current and expected behavior

7.24.0: it prints [2, 1, 3]
main: it prints [1, 3, 2]
expected: it should print [1, 2, 3]

Environment

REPL

Possible solution

No response

Additional context

As a workaround, you can add a dummy decorator to any class elements, then the evaluation order will be correct.
For example,

const dummy = () => {}

const logs = [];

@dummy
class C {
  @dummy
  [(logs.push(1), 1)];
  static [(logs.push(2), 2)];
  [(logs.push(3), 3)];
}

console.log(logs);
@babel-bot
Copy link
Collaborator

Hey @JLHwung! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants