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

cannot reassign to a class #43125

Closed
1 task done
Janpot opened this issue Nov 19, 2022 · 2 comments
Closed
1 task done

cannot reassign to a class #43125

Janpot opened this issue Nov 19, 2022 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Janpot
Copy link
Contributor

Janpot commented Nov 19, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101
    Binaries:
      Node: 16.17.0
      npm: 8.15.0
      Yarn: 1.22.19
      pnpm: 7.14.2
    Relevant packages:
      next: 13.0.4
      eslint-config-next: 13.0.3
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Noticed this while trying out transpilePackages on the monaco-editor package.

It contains some code That reassigns to a class, simple reproduction:

class X {}
X = {};

I believe this type of code is generated by tsc for namespaces in https://github.com/microsoft/vscode/blob/63f8550155e5ac7b83e1828002e272e6e44f50d3/src/vs/base/common/color.ts#L485. See this typescript playground example

Next.js throws an error for this code

   x cannot reassign to a class
     ,-[16:1]
  16 | class X {}
     :       |
     :       `-- class name
  17 | 
  18 | // @ts-expect-error
  19 | X = {};
     : ^
     `----

yet this is valid javascript

Expected Behavior

No error, this is valid javascript

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://codesandbox.io/s/suspicious-bell-7nonzn?file=/pages/index.js

To Reproduce

Open the code sandbox, look at the terminal

related swc-project/swc#6471

@Janpot Janpot added the bug Issue was opened via the bug report template. label Nov 19, 2022
@Janpot
Copy link
Contributor Author

Janpot commented Nov 21, 2022

Fixed in canary

@Janpot Janpot closed this as completed Nov 21, 2022
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

1 participant