Skip to content

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

@iShibi

Description

@iShibi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions