Skip to content

Variable used in 'key' appears as unused #329

Closed
@Kruptein

Description

@Kruptein

The below template gives a "'i' is declared but its value is never read." in both volar and vue-tsc.

<template v-for="[i, part] of someObject" :key="i">
  {{ part }}
</template>

While the i is indeed not used inside the template itself, it is used in the key and can thus not simply be removed.

A temporary workaround can be:

<template v-for="something of someObject" :key="something[0]">
  {{ something[1] }}
</template>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions