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

v-for looses types for iterating over object #117

Closed
zigomir opened this issue Mar 29, 2021 · 2 comments
Closed

v-for looses types for iterating over object #117

zigomir opened this issue Mar 29, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@zigomir
Copy link
Contributor

zigomir commented Mar 29, 2021

Hi – your plugin is amazing, thanks so much for creating it!

This issue is probably similar to #104 but maybe this can be improved.

For a component

<template>
  <div>
    <div v-for="(value, key) in obj">
      <span>{{key}}</span>: {{ value.toFixed() }}
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  setup() {
    const obj: Record<'key1' | 'key2', number> = {
      key1: 1,
      key2: 2,
    }

    return { obj }
  }
})
</script>

I get these on hover

  1. obj is correctly typed

Screenshot 2021-03-29 at 15 13 19

  1. value is any while it should be number

Screenshot 2021-03-29 at 15 13 24

  1. key is string while it should be 'key1' | 'key2'

Screenshot 2021-03-29 at 15 14 16

This is a reproduction repo.

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Mar 29, 2021
@johnsoncodehk
Copy link
Member

Fixed in 0.22.24, thanks for the report!

@zigomir
Copy link
Contributor Author

zigomir commented Mar 29, 2021

Amazing – thank you very much – it now works very well with a lot more complex object! 🎉

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