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

Keep original class name when decorator is applied #1656

Closed
egoist opened this issue May 8, 2021 · 2 comments
Closed

Keep original class name when decorator is applied #1656

egoist opened this issue May 8, 2021 · 2 comments
Labels

Comments

@egoist
Copy link

egoist commented May 8, 2021

Describe the bug

class name is changed when decorator is also used, e.g. class Foo becomes class Foo1.

Input code

@ObjectType()
class Foo {}

Output code

var _class;
var _dec = ObjectType();
let Foo = _class = _dec((_class = class Foo1 {
}) || _class) || _class;

Config

{
      jsc: {
          parser: {
          syntax: 'typescript',
          decorators: true,
          dynamicImport: true,
          },
      transform: {
          legacyDecorator: true,
          decoratorMetadata: true,
      },
        target: 'es2019',
    },
}

Expected behavior

class names should not be changed

Version
The version of @swc/core: 1.2.55

Additional context

libraries like https://typegraphql.com/ relies on the original class name to determine output graphql type name.

@egoist egoist added the C-bug label May 8, 2021
@kdy1
Copy link
Member

kdy1 commented May 8, 2021

You can use jsc.keepClassNames. See: https://swc.rs/docs/configuring-swc/#jsckeepclassnames

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 24, 2022

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 Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants