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

Using accessor as class method results in incorrect code. #7042

Closed
AlexanderSimacan opened this issue Mar 9, 2023 · 2 comments · Fixed by #7046
Closed

Using accessor as class method results in incorrect code. #7042

AlexanderSimacan opened this issue Mar 9, 2023 · 2 comments · Fixed by #7046
Assignees
Labels
Milestone

Comments

@AlexanderSimacan
Copy link

Describe the bug

When compiling a class with a method named accessor, the resulting code removes the method name.

Input code

class SomeClass {
    accessor() {
        return '🦦';
    }
}
class SomeOtherClass {
    static accessor() {
        return '🦦';
    }
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": {
        "toplevel": false,
        "keep_classnames": false,
        "keep_fnames": false,
        "keep_private_props": false,
        "ie8": false,
        "safari10": false
      }
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link

https://play.swc.rs/?version=1.3.38&code=H4sIAAAAAAAAA0vOSSwuVgjOz011BrOquRSAIDE5ObW4OL9IQxMqAAJFqSWlRXkK6h%2FmL1umbg0WruWq5UqGm%2BBfkpFahGxMcUliSWYySaYBACfgxeKQAAAA&config=H4sIAAAAAAAAA22PzQrCQAyE3yXnHrQHkb6DzyBhzZbV%2FQnJtljKvrvbUlsETxnmG8LMDE810M3AKEqyKJ1ixjd0kCcmNeI4QwNZq5VloFI1Sk%2B5JkjbU9tW6lNSgs6iV2oguOjstPwyKbCQ6oEw9p4WlBN7Gsnv6EXEd%2BNRNWIg%2FfXtH4%2FFjZip3sQHcnTdtaJFcefTZpRSy4f0GLYGdd864gLlKP19o7ctuI7%2BAI9bgSwoAQAA

Expected behavior

SWC correctly compiles classes with methods named accessor.

Actual behavior

The compilation removes the name of methods named accessor.

Version

1.3.38

Additional context

This is also a problem when using Axios:
https://github.com/axios/axios/blob/v1.x/lib/core/AxiosHeaders.js#L262

@kdy1 kdy1 added this to the Planned milestone Mar 9, 2023
@kdy1 kdy1 self-assigned this Mar 9, 2023
@kdy1
Copy link
Member

kdy1 commented Mar 9, 2023

Oh.. I think this is caused by accessor support PR

kdy1 pushed a commit that referenced this issue Mar 10, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.40 Mar 13, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Apr 12, 2023

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants