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

Unable to parse the # symbol for private methods of a class #318

Closed
6 tasks done
iShibi opened this issue Dec 26, 2021 · 2 comments
Closed
6 tasks done

Unable to parse the # symbol for private methods of a class #318

iShibi opened this issue Dec 26, 2021 · 2 comments

Comments

@iShibi
Copy link

iShibi commented Dec 26, 2021

Describe the bug

ℹ️ I've opened a related issue at acornjs as requested: acornjs/acorn-class-fields#17

Vitest throws error when testing an instance of a class that implements a private method. The error occurs because private method's name starts with the # symbol which it is unable to parse.

The project that I'm trying to add vitest to: twitterjs/twitter.js#96

Reproduction

https://stackblitz.com/edit/node-stkuzb

System Info

System:
  OS: Windows 10 10.0.19043
  CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics
  Memory: 2.09 GB / 7.36 GB
Binaries:
  Node: 16.9.0 - ~\AppData\Local\Volta\tools\image\node\16.9.0\node.EXE      
  Yarn: 1.22.11 - ~\AppData\Local\Volta\tools\image\yarn\1.22.11\bin\yarn.CMD
  npm: 7.24.2 - ~\AppData\Local\Volta\tools\image\npm\7.24.2\bin\npm.CMD     
Browsers:
  Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.62)
  Internet Explorer: 11.0.19041.1202
npmPackages:
  vitest: ^0.0.113 => 0.0.113

Used Package Manager

npm

Logs

FAIL  src/client/__tests__/Client.test.ts [ src/client/__tests__/Client.test.ts ]
Error: Parse failure: Unexpected token (60:8)
Contents of line 60:   async #fetchClientUser(username) {
 ❯ ssrTransform node_modules/vite/dist/node/chunks/dep-fcec4469.js:56614:15
 ❯ doTransform node_modules/vite/dist/node/chunks/dep-fcec4469.js:57940:48
 ❯ processTicksAndRejections ../../../node:internal/process/task_queues:96:5

Validations

@iShibi
Copy link
Author

iShibi commented Dec 26, 2021

from the above mentioned issue:

As of Acorn 8.2.0 private fields and private methods are supported in Acorn without the need to use this (or another) plugin, I recommend upgrading Acorn.

acornjs/acorn-class-fields#17 (comment)

@sheremet-va
Copy link
Member

Should be fixed in 0.0.120

chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants