Generic components throw errors
Vue version
3.2.47
Link to minimal reproduction
https://github.com/vuejs/language-tools/files/11343091/vue-project.zip
Steps to reproduce
NOTE: The repro project is based on 'npm init vue@latest' from today. All I changed after was updating vue-tsc package from 1.2.0 to 1.6.0. Then I added the important repro generic component called CList.
- Open the repro project in VSCode
- Make sure Takeover mode is enabled (by disabling 'TypeScript and JavaScript Language Features' in workspace)
- Run 'npm i'
- Run 'npm run dev'
- Aforementioned errors will be thrown on build/startup by Vite
The errors are thrown only when using <** or **> chars inside the generic attribute.
If you try replacing generic="TItem extends Item<TValue>, TValue"
with generic="TItem extends SimpleItem"
inside the CList component then the errors disappear.
What is expected?
No error to be thrown. This was previously working.
What is actually happening?
My generic components started throwing errors like "Unexpected ","" or "Unterminated string literal" after the Volar extension and vue-tsc package 1.6.0 update (at least I believe this was the trigger). After consulting Volar language-tools repo I was redirected here.
System Info
System:
OS: Windows 10 10.0.22621
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 20.51 GB / 31.92 GB
Binaries:
Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.1555.0), Chromium (112.0.1722.58)
Internet Explorer: 11.0.22621.1
npmPackages:
vue: ^3.2.47 => 3.2.47
Any additional comments?
No response
The author's description of the problem is not very clear, when he actually reproduced the problem, he did not run vue-tsc
but ran vite
, so it's not related to upgrading vue-tsc / Volar.
@yyx990803
Running vue-tsc --noEmit
gives no errors.
Errors happen right after running npx vite
, so it is as @johnsoncodehk says.
Full error description: `Error: Failed to scan for dependencies from entries: E:/Downloads/Test/vue-project/index.html
X [ERROR] Unexpected ","
script:E:/Downloads/Test/vue-project/src/components/CList.vue?id=1:1:0:
1 │ , TValue">
╵ ^
at failureErrorWithLog (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1636:15)
at E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1048:25
at runOnEndCallbacks (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1471:45)
at buildResponseToResult (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1046:7)
at E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1058:9
at new Promise (<anonymous>)
at requestCallbacks.on-end (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:1057:54)
at handleRequest (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:723:19)
at handleIncomingPacket (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:745:7)
at Socket.readFromStdout (E:\Downloads\Test\vue-project\node_modules\esbuild\lib\main.js:673:7)`
NOTE: I also tried updating vue
to 3.3.0-beta.2 to no avail.
@johnsoncodehk I noticed possibly related stuff in language-tools updates (1.6.2, 1.6.3) that came since reporting this issue. Now it sometimes works, sometimes doesnt.
The weirdest thing is that the website runs perfectly whether the error occurs or not.
I will try to find out why the error sometimes occurs and sometimes doesnt.
Just a little bit stressed that this issue was closed right away and not reopened. The repro project is sound.
This is what I see
EDIT: New observation: I start getting the error after running 'npm i' after updating 'vue-tsc' package (but perhaps after updating any package). Then, after some time (perhaps after restarting the PC), I stop getting the error again. This is literally what happened right now.
I guess this is related to reported issue: https://github.com/vitejs/vite-plugin-vue/issues/162
This error is upstream in Vite core - I've created a fix PR at https://github.com/vitejs/vite/pull/13101 Closing this one to track in Vite instead.