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

Inheritance Issue with SWC Compilation #8577

Closed
y1j2x34 opened this issue Jan 30, 2024 · 2 comments
Closed

Inheritance Issue with SWC Compilation #8577

y1j2x34 opened this issue Jan 30, 2024 · 2 comments
Labels

Comments

@y1j2x34
Copy link

y1j2x34 commented Jan 30, 2024

Describe the bug

I am currently facing an issue while upgrading an old project to use SWC for compilation. The project consists of both JavaScript and TypeScript files, and there is a scenario where a TypeScript class (New.ts) extends a JavaScript class (Old.js). The TypeScript class includes a private property value, but during SWC compilation, this property is transformed into _define_property._(_assert_this_initialized._(_this), "value", void 0);, leading to value being overwritten as undefined.

Input code

// file: Old.js
class Old {
    constructor() {
        this.value = 123;
    }
}

// file:  New.ts
class New extends Old{
    private value!: number;
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es5",
    "externalHelpers": true,
    "minify": {
      "compress": false,
      "mangle": false
    },
    "keepClassNames": true,
    "loose": false
  },
  "minify": false,
  "isModule": true,
  "module": {
    "type": "umd"
  }
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.107&code=H4sIAAAAAAAAAzXMQQ7CIBQE0P0%2FxbjTDUTdtfEKegak34hBauDTNmm4uy3a2c1M8rTGw3lucPOdeiWy3qS0FsyEJbYPSWK20sf94b%2BtkadLajA%2BMy44ns5tfQoVIr2RuPKoZDOXAp6EQ1f9H%2FWJbjDCqNKuQcjvO8eWyhfiG7IxmAAAAA%3D%3D&config=H4sIAAAAAAAAA22Quw6DMAxFd74Cee7apWuXLu0%2FWGBQ2rxkGwmE%2BPcmlFBUdYvvyc1RPFd1DU9p4FLP6ZiGiCzE%2B5wSmbzimBLQKZI0bKLCqVCVjDq0Qmu0fAgock%2BaWyTn7TrQqMQe7Y1sJJZElQfaoDPedNPR3AQXmUSKYJc69L2lv94XUbxaFHmgox%2BDDUGOrbXz9e4OMHIP7bAaSh1cSbZF5WXk7w2uhfxWtbwBcTGuOk0BAAA%3D

SWC Info output

No response

Expected behavior

We expect that when inheriting properties from a parent class, the initialization and access of those properties should remain intact during SWC compilation.

Actual behavior

No response

Version

1.3.107

Additional context

No response

@y1j2x34 y1j2x34 added the C-bug label Jan 30, 2024
@kdy1
Copy link
Member

kdy1 commented Feb 2, 2024

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Mar 3, 2024

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 Mar 3, 2024
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