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

ts(6133): never read in v-for if only using the index #878

Closed
panwauu opened this issue Jan 20, 2022 · 1 comment
Closed

ts(6133): never read in v-for if only using the index #878

panwauu opened this issue Jan 20, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@panwauu
Copy link

panwauu commented Jan 20, 2022

I use v-for sometimes for iterating using the index of an array. Normally in typescript I can use "_" to ignore the first parameter and only use the second one. Using Volar I always get an error.

<div v-for="(_, i) in ['a','b','c']">{{i}}</div>
'_' is declared but its value is never read.ts(6133)

Workarounds are:

<div v-for="(_, i) in ['a','b','c']">{{i}}</div> // Renders: 0 1 2; Leads to ts error
<div v-for="i in ['a','b','c'].length">{{i}}</div> // Renders: 1 2 3; Workaround a
<div v-for="i in [...Array(['a','b','c'].length).keys()]">{{i}}</div> // Renders: 0 1 2; Workaround b

Old issue: johnsoncodehk/vue-tsc#59

Related problem: #329
Here the issue is, that the variable is used in :key but volar does not recognize that it is actually used

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Jan 20, 2022
@johnsoncodehk
Copy link
Member

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants