Subscribe on changes!

Type mismatch between :key & v-for index

avatar
Apr 6th 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

avatar
Apr 6th 2021

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.

avatar
Apr 6th 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...

avatar
Apr 6th 2021

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

avatar
Apr 6th 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