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

Type mismatch between :key & v-for index #3547

Closed
valdoryu opened this issue Apr 6, 2021 · 5 comments
Closed

Type mismatch between :key & v-for index #3547

valdoryu opened this issue Apr 6, 2021 · 5 comments

Comments

@valdoryu
Copy link

valdoryu commented Apr 6, 2021

Version

3.0.11

Reproduction link

https://gofile.io/d/RgpasT

Steps to reproduce

Every project using typescript & having a v-for

Reproduction is just a dummy ts component with a v-for. Using it in VSCode with Volar will display the error

What is expected?

V-for "index" arg type is defined as:
const index: string | number | symbol

What is actually happening?

"Key" prop type is defined as:
(property) key?: string | number | undefined

As you can see, it is missing symbol coverage, producing type errors if we don't manually toString() or parseInt() the index in the template

@edison1105
Copy link
Member

I think this is about Volar and string | number is recommended key type, not symbol.
BTW, We recommend using sfc.vuejs.org to create a reproduction.

@yyx990803
Copy link
Member

yyx990803 commented Apr 6, 2021

I can't reproduce this locally and your file download link doesn't seem to work (stuck at downloading)

Just pasting the content of the file directly here would be easier...

@edison1105
Copy link
Member

edison1105 commented Apr 6, 2021

@yyx990803
What he was trying to say was probably this:
image
Volar display an error.

@posva
Copy link
Member

posva commented Apr 6, 2021

Duplicate of #2633

@posva posva marked this as a duplicate of #2633 Apr 6, 2021
@posva posva closed this as completed Apr 6, 2021
@valdoryu
Copy link
Author

valdoryu commented Apr 6, 2021

Sorry guys, I tried to reproduce with typescript in the proposed repro tools without success.
I'll try better next time.

Issue is indeed #2633

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