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

template with v-for and index does not recognise :key="index" #3139

Closed
jfrs opened this issue May 6, 2023 · 3 comments
Closed

template with v-for and index does not recognise :key="index" #3139

jfrs opened this issue May 6, 2023 · 3 comments
Labels
duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@jfrs
Copy link

jfrs commented May 6, 2023

Doing something like this

  <template v-for="(test, index) in ['a', 'b', 'c']" :key="index">
    <div>{{ test }}</div>
  </template>

results in 'index' is declared but its value is never read.ts(6133) and there is no IntelliSense on :key="index".

Vue 3.2.47, Volar 1.6.4

@dockfries
Copy link

dockfries commented May 8, 2023

<template>
  <div>
    <!-- similar closing tag intellisense issue -->
    <!-- Although v-for is recommended for computed or variables -->
    <!-- v-for uses index and calls function, exception -->
    <div v-for="(item, index) in foo('bar')" :key="item.id"></div>
    <!-- v-for uses string array, exception -->
    <div v-for="(item, index) in ['foo']" :key="item.id"></div>
    <!-- v-for without index, normal -->
    <div v-for="item in foo('bar')" :key="item.id"></div>
    <div v-for="item in ['foo']" :key="item.id"></div>
  </div>
</template>

VSCode Version: 1.78.0, Volar 1.6.4

@NathanAP
Copy link

Actually happening for me as well but only if I use v-for in a template.

<template
    v-for="(column, index) in myArray" // -> I get ts6133 in index
    :key="index" 
>

Other elements works fine.

@johnsoncodehk
Copy link
Member

Duplicate of #329

@johnsoncodehk johnsoncodehk marked this as a duplicate of #329 Jun 28, 2023
@johnsoncodehk johnsoncodehk closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@johnsoncodehk johnsoncodehk added duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

4 participants