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

SystemJS constructors drop all references to this and replace with void 0 #8505

Closed
branks opened this issue Jan 15, 2024 · 1 comment · Fixed by #8506
Closed

SystemJS constructors drop all references to this and replace with void 0 #8505

branks opened this issue Jan 15, 2024 · 1 comment · Fixed by #8506
Labels
Milestone

Comments

@branks
Copy link

branks commented Jan 15, 2024

Describe the bug

When transpiling to SystemJS, anything that uses classes (> es5) seems to drop references to this in the constructor and replace them with void 0

Input code

export default () => {
    class Rectangle {
        height: number = 0;
        constructor(height, width) {
            this.height = height;
            this.width = width;
        }
        incrementHeight() {
            this.height = this.height + 1
        }
    }
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2022",
    "transform": {
      "react": {
        "runtime": "automatic"
      }
    },
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    },
  },
  "module": {
    "type": "systemjs"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.103&code=H4sIAAAAAAAAA32PwQ7CIBBE73zF3tpGY%2FRqUy9ePPsHSLeFpICBJZo0%2FLuUmtpo4lyYZd4OQem7dQQjnG1yBg1BhM5ZDYVDLqioGcNnZlrseBgIygqaE4wMksTAvYcrCuKmH%2FB9O0mi6iUdwQR9QwcN7OslE9Z4ckGQdeXMbeGhWpLVqmASSeV3M5EaZlP%2FEnk3Afn85HFxygiHOn3ukivK%2F%2B%2Bspw0cvvoiiy9DTOloNQEAAA%3D%3D&config=H4sIAAAAAAAAA2WQPQ6DMAyFd06BPHeoGHuHHsJKDQoiP7IdqRHi7iWUUFCXKP6e7Wd7btoWRjHwaOf1uwYRWYiPeCWSveJ7JaA5khi2UeFWVZUi9TgJbWj5KqDIA2mpIunuXQeVM3rpA7uzBRMaPYGCklfrqDTApMGhWgO7vFycphCE6gw7c9bbPp8tTHCRSeSaWFLRDxP977A94MIrbep%2BnnKCMpNkUXKjwC%2BzWh7twcqzlisnapYPVBcUQG8BAAA%3D

SWC Info output

No response

Expected behavior

The void 0 should be using this instead

System.register([], function(_export, _context) {
    "use strict";
    return {
        setters: [],
        execute: function() {
            _export("default", ()=>{
                class Rectangle {
                    height = 0;
                    constructor(height, width){
                        this.height = height;
                        this.width = width;
                    }
                    incrementHeight() {
                        this.height = this.height + 1;
                    }
                }
            });
        }
    };
});

Actual behavior

System.register([], function(_export, _context) {
    "use strict";
    return {
        setters: [],
        execute: function() {
            _export("default", ()=>{
                class Rectangle {
                    height = 0;
                    constructor(height, width){
                        (void 0).height = height;
                        (void 0).width = width;
                    }
                    incrementHeight() {
                        this.height = this.height + 1;
                    }
                }
            });
        }
    };
});

Version

1.3.103

Additional context

No response

@branks branks added the C-bug label Jan 15, 2024
@kdy1 kdy1 added this to the Planned milestone Jan 16, 2024
kdy1 pushed a commit that referenced this issue Jan 16, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.3.104 Jan 17, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 16, 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 Feb 16, 2024
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