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

addInitializer of ClassFieldDecoratorContext not called during construction #9708

Open
shunueda opened this issue Nov 3, 2024 · 0 comments · May be fixed by #9488
Open

addInitializer of ClassFieldDecoratorContext not called during construction #9708

shunueda opened this issue Nov 3, 2024 · 0 comments · May be fixed by #9488
Assignees
Labels

Comments

@shunueda
Copy link

shunueda commented Nov 3, 2024

Describe the bug

addInitializer for ClassFieldDecoratorContext should be called during construction (tc39/proposal-decorators).

Input code

const decorator = (value, context) => {
  context.addInitializer(() => {
    console.log("init")
  })
}

class A {
  @decorator
  field
}

const a = new A()

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "tsx": false
    },
    "transform": {
      "decoratorVersion": "2022-03"
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.42&code=H4sIAAAAAAAAAz3OSwrDMAwE0L1OIbKyoeQGKc2yxxC2GgTCAlv90JK71xiS5QwPZpKV5pg5WSW3iguGF%2BmTL5isOH884nLFH%2BCRZ8r5XsSFVL5cQzjBIM2UZ7UtTNLRFHu%2FR9gBklJruA55O%2Fd6eAhrHmJcoX6h8BvXEOEPENdugZ0AAAA%3D&config=H4sIAAAAAAAAA1VQQQ6DMAy78wqU8yYhJu2wP%2By6e9UF1Ik2VVKkIcTf1wLt4JbYTmx5ruoaPqLhUc9xjItXLMhlj4hMLqhvRCBMHkWz8QEumX2jJlaBWKIi8IiFCZKOOjUIrtCyMRBYOemI7dGkvHkhiyGX7Nqmba%2FNDc7XinsMiUZJgj0JDESC2W%2FHrHGmm442mqxnFDkLk1S5fsBz3mp3BUvvcSX3jlIPW4I7%2FEXZrDwGI898mZqplh%2Fgqb%2BcbwEAAA%3D%3D

SWC Info output

No response

Expected behavior

"init" in stdout

Actual behavior

No output

Version

1.7.42

Additional context

Does NOT work for static fields either: playground

DOES work for methods (static too): playground

@shunueda shunueda added the C-bug label Nov 3, 2024
@shunueda shunueda changed the title addInitializer for ClassFieldDecorator is not called during construction addInitializer for ClassFieldDecoratorContext not called during construction Nov 3, 2024
@shunueda shunueda changed the title addInitializer for ClassFieldDecoratorContext not called during construction addInitializer of ClassFieldDecoratorContext not called during construction Nov 3, 2024
@kdy1 kdy1 added this to the Planned (Low priority) milestone Nov 4, 2024
@kdy1 kdy1 self-assigned this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants