vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.88k stars 407 forks source link

`vue-tsc` CLI rest params runtime error in version `2.0.19` and beyond #4578

Open pdhoopr opened 4 months ago

pdhoopr commented 4 months ago

Vue - Official extension or vue-tsc version

vue-tsc@2.0.19

VSCode version

1.91.1

Vue version

3.4.31

TypeScript version

5.4.5

System Info

System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M3 Pro
  Memory: 83.59 MB / 18.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.12.0 - ~/.asdf/installs/nodejs/20.12.0/bin/node
  Yarn: 3.6.3 - ~/.asdf/installs/nodejs/20.12.0/bin/yarn
  npm: 10.5.0 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
  Safari: 17.5

Steps to reproduce

Unfortunately, I'm not able to track down exactly what in our code is triggering the error, but I can provide some additional context/learnings I've come across. It seems like it might be related to rest parameters:

What is expected?

vue-tsc successfully runs to completion, reporting errors along the way (if any).

What is actually happening?

vue-tsc encounters a runtime error from tsc and errors out. The stack trace logged to the console is:

TypeError: Cannot read properties of undefined (reading 'flags')
    at getCheckFlags (/app/node_modules/typescript/lib/tsc.js:15948:17)
    at getTypeOfSymbol (/app/node_modules/typescript/lib/tsc.js:53297:24)
    at getParameterCount (/app/node_modules/typescript/lib/tsc.js:73708:24)
    at getRestTypeAtPosition (/app/node_modules/typescript/lib/tsc.js:73679:28)
    at assignContextualParameterTypes (/app/node_modules/typescript/lib/tsc.js:73835:41)
    at contextuallyCheckFunctionExpressionOrObjectLiteralMethod (/app/node_modules/typescript/lib/tsc.js:74560:13)
    at checkFunctionExpressionOrObjectLiteralMethod (/app/node_modules/typescript/lib/tsc.js:74535:5)
    at checkExpressionWorker (/app/node_modules/typescript/lib/tsc.js:76319:16)
    at checkExpression (/app/node_modules/typescript/lib/tsc.js:76221:32)
    at checkExpressionForMutableLocation (/app/node_modules/typescript/lib/tsc.js:75979:18)

Link to minimal reproduction

No response

Any additional comments?

Based on the details provided in the steps to reproduce section, I can't tell if there's actually anything that can be done from a vue-tsc perspective, or if this needs to be solved on the tsc side.

Thank you!!

johnsoncodehk commented 4 months ago

Thank you for your report and collection of relevant information! https://github.com/vuejs/language-tools/commit/86e38db1a531b1cce24814da4a5c42aef75d987b#diff-93ac10dff6acb9af8511a96c6ef3bdabf647f4ed0a85a9fe1566a0cf320cf44aR157 is to fix the TS type of parameterless event. I have not yet come up with an alternative way of writing virtual code. Unfortunately, we may have to wait for https://github.com/microsoft/TypeScript/pull/58440 to be merged.