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

Incorrect destructured type seems to be passed to v-for value, throws ts(2339) error #3102

Closed
MajesticPotatoe opened this issue May 1, 2023 · 1 comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@MajesticPotatoe
Copy link

MajesticPotatoe commented May 1, 2023

Environment:
OS: OSX 13.3.1 (22E261)
Vue Language Features (Volar) Version: v1.6.2
TypeScript Vue Plugin (Volar) Version: v1.6.2

in v 1.6.1 the following code works:

<script setup lang="ts">
  type Item = {
    id: number,
    text: string
  }
  const items = ref(null as null | Item[])
</script>

<template>
  <div
    v-for="item in items"
    :key="item?.id"
  >
    <div>{{ item?.id }}</div>
    <div>{{ item?.text }}</div>
  </div>
</template>

items has its correct type of Item[] | null, and item has the type of Item, no error is thrown.
in v1.6.2, item is receiving the inferred type of never and throwing Property '' does not exist on type 'never'. ts(2339)
Screenshot 2023-05-01 at 3 52 42 PM

Workaround
Revert to version 1.6.1 of Vue Language Features (Volar).

@johnsoncodehk johnsoncodehk added the bug Something isn't working label May 1, 2023
@johnsoncodehk
Copy link
Member

Fixed by 83e9ece

@johnsoncodehk johnsoncodehk added the good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first label May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 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

2 participants