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

Typing lost in template 'for loop' for array item #4742

Closed
holloway opened this issue Aug 29, 2024 · 3 comments
Closed

Typing lost in template 'for loop' for array item #4742

holloway opened this issue Aug 29, 2024 · 3 comments

Comments

@holloway
Copy link

holloway commented Aug 29, 2024

Vue - Official extension or vue-tsc version

2.1.0

VSCode version

1.92.2

Vue version

3.4.38

TypeScript version

5.5.4

System Info

No response

Steps to reproduce

This is a regression in Vue - Official extension 2.1.0 and it works in 2.0.28.

Template's v-for="item in array" would lose the typing of item

Example

<template>
  <Menu v-for="(menuItem, index) in menuData" :key="index">
    <MenuButton>{menuItem.label}</MenuButton>
    <MenuItems>
      <MenuItem
        v-for="(child, childImdex) in menuItem.children"
        :key="childImdex"
        v-slot="{ active }"
      >
        <a :class="{ 'bg-blue-500': active }" href="/"> test </a>
      </MenuItem>
    </MenuItems>
  </Menu>
</template>

<script setup lang="ts">
type MenuItem = {
  label: string
  children: { label: string; href: string }[]
}

const menuData: MenuItem[] = [
  {
    label: 'Documents',
    children: [
      { label: 'a', href: '/a' },
      { label: 'b', href: '/b' }
    ]
  },
  {
    label: 'About',
    children: [
      { label: 'a', href: '/a' },
      { label: 'b', href: '/b' }
    ]
  },
  {
    label: 'Authoring',
    children: [
      { label: 'a', href: '/a' },
      { label: 'b', href: '/b' }
    ]
  },
  {
    label: 'Reports',
    children: [
      { label: 'a', href: '/a' },
      { label: 'b', href: '/b' }
    ]
  }
]
</script>

What is expected?

item would have typing

What is actually happening?

item does not have typing

Link to minimal reproduction

No response

Any additional comments?

No response

@RayGuo-ergou
Copy link
Contributor

Likely is fixed via #4740

Let's wait for the next release and see!

@KazariEX
Copy link
Collaborator

Can't reproduce with 2.1.0, has the 2.1.2 fixed it?

@holloway
Copy link
Author

Yes 2.1.2 fixes it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants