swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
31.23k stars 1.23k forks source link

Anonymous class TS method decorator broken #8095

Closed lucacasonato closed 1 year ago

lucacasonato commented 1 year ago

Describe the bug

SWC fails to apply legacy TS method decorators for anonymous classes.

Input code

const foo = class { @foo foo(v){return v} }

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": true
    },
    "target": "es5",
    "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.3.74&code=H4sIAAAAAAAAA0vOzysuUUjLz1ewVUjOSSwuVqhWcABxgVijTLO6KLWktChPoaxWoRYAm3SIQysAAAA%3D&config=H4sIAAAAAAAAA2WPQQ7DIAwE73lF5HOv7aF%2F6CMQcSIqwMh2pEZR%2Fl4CCW3VG97Bu96163t4ioV7v%2BZnHpJhQW5zVmSJal5ZAV0SimWXFC4nVdnRaLxg0wa0xEaJJSPlGQvYKgc1PKHufijXwwg8keCvEQQX3bh8n2IpJEaRv8Rg4uTbfo3rjkgINMwFHhX3GjX%2BBp9PZ1gzBiePc7OU2N6FM0VqLgEAAA%3D%3D

SWC Info output

No response

Expected behavior

This should not error with _class is not defined

Actual behavior

Errors with _class is not defined

Version

1.3.74

Additional context

No response

swc-bot commented 1 year ago

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.