Skip to content

[Bug]: @babel/plugin-proposal-decorators, auto-accessors affect other initializers #15050

@rauschma

Description

@rauschma

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/register or @babel/node

Input code

function init(_value, {name, addInitializer}) {
  addInitializer(function () {
    console.log(name, typeof this);
  });
}
class C {
  @init static accessor staticAcc;
  @init protoMethod() {}
}
console.log('=== Instantiation ===');
const inst = new C();

Configuration file name

babel.config.json

Configuration

{
  "plugins": [
    ["@babel/plugin-proposal-decorators", {"version": "2022-03"}]
  ]
}

Current and expected behavior

Actual output:

staticAcc function
protoMethod function
=== Instantiation ===

Expected output:

staticAcc function
=== Instantiation ===
protoMethod object

With the accessor commented out, the output is:

=== Instantiation ===
protoMethod object

Environment

  System:
    OS: macOS 12.6
  Binaries:
    Node: 18.10.0 - /usr/local/bin/node
    npm: 8.19.2 - /usr/local/bin/npm
  npmPackages:
    @babel/core: ^7.19.3 => 7.19.3 
    @babel/node: ^7.19.1 => 7.19.1 
    @babel/plugin-proposal-decorators: ^7.19.3 => 7.19.3 

Possible solution

No response

Additional context

Metadata

Metadata

Assignees

Labels

Spec: DecoratorsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions