`vue-tsc` CLI rest params runtime error in version `2.0.19` and beyond
Vue - Official extension or vue-tsc version
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:
- In
[email protected], this type change was made to event handlers. - For some reason, that change started triggering an error from the
tscruntime, which has an open issue and potential fix, but hasn't been resolved yet. - However,
vue-tscwas not surfacing runtime errors, so after upgrading to2.0.19, the type checker was encountering the runtime error above and silently erroring out itself without reporting any type errors. This gave the appearance that it finished successfully, so we didn't catch it right away. - In
[email protected], this change was made to surface runtime errors, and so now our type-checking errors out as it should.
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!!
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.