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

Generic components throw errors #8171

Closed
StepanMynarik opened this issue Apr 27, 2023 · 6 comments
Closed

Generic components throw errors #8171

StepanMynarik opened this issue Apr 27, 2023 · 6 comments

Comments

@StepanMynarik
Copy link

StepanMynarik commented Apr 27, 2023

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.

  1. Open the repro project in VSCode
  2. Make sure Takeover mode is enabled (by disabling 'TypeScript and JavaScript Language Features' in workspace)
  3. Run 'npm i'
  4. Run 'npm run dev'
  5. 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

@yyx990803
Copy link
Member

This seems to be a regression in Volar when paired with 3.2.x - /cc @johnsoncodehk

@johnsoncodehk
Copy link
Member

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.

@StepanMynarik
Copy link
Author

StepanMynarik commented Apr 28, 2023

@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.

@StepanMynarik
Copy link
Author

StepanMynarik commented May 3, 2023

@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
image

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.

@yyx990803 yyx990803 reopened this May 3, 2023
@jd-solanki
Copy link

I guess this is related to reported issue: vitejs/vite-plugin-vue#162

yyx990803 added a commit to vitejs/vite that referenced this issue May 5, 2023
…s ">"

The case occurs with Vue 3 generics usage but is technically possible in other scenarios as well

ref: vuejs/core#8171
@yyx990803
Copy link
Member

This error is upstream in Vite core - I've created a fix PR at vitejs/vite#13101
Closing this one to track in Vite instead.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 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

4 participants