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

Generic props inference in template breaks when directly referring to prop by name #3820

Closed
LinusBorg opened this issue Dec 22, 2023 · 4 comments · Fixed by #3838
Closed
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream

Comments

@LinusBorg
Copy link
Member

<script setup lang="ts" generic="T extends { name: string }">
const props = defineProps<{
    one: T;
    all: Array<T>;
}>();
</script>
<template>
    <div>
        <!-- incorrect inference -->
        <div>{{ one.name }}</div>
        <!-- correct inference -->
        <div>{{ props.one.name }}</div>
        <ul>
          <!-- correct inference -->
          <li v-for="el in all">{{ el.name }}</li>
        </ul>
    </div>
</template>

https://play.vuejs.org/#eNp9Uj1vgzAQ/SsnT63UwpCNOpHSKkM7tFHL6AXBhTo1tmUbmgrx33uGfDBEYcHv7vnx7nE9W1ubdC2yjHFfOmkDeAytBVXoeilY8IJBjRqdLAnmgIeAuvLQgy4azMAHJ3UNg2AroUujfQDrjPWwhAp3UuM2It4LDfQYTVfypwkUSmWwdq744/mKasPq7p5ePJ2MkB4P2FhVBKRzvMEr2R2PZ9j3UTWJbmAYeHqdMnpKbhFbNUOElYTucWccTY0KpI52aUjSQnURUXKukZ5FTvI8nY3AHihPymgn62TvjabQx1wEK01jpUL3YYOkDAXL4JiYYPRd8/s21oJr8eFUL7+x/LlS3/tDrAm2dejRdSjYuRcKV2OY2puvd/qZs2ZjqlYR+0bzE71RbfQ40Z5bXZHtGW90+9pY4wLtRe43cV/8aahoNDKHkS8Ybd7LjdEvdhfJYrxHW8KGf2FN3Vg=

@so1ve
Copy link
Member

so1ve commented Dec 22, 2023

fixed by #3786

@so1ve so1ve added bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Dec 22, 2023
@ThibaudDauce
Copy link

Thanks a lot!

@sphex813
Copy link

fixed by #3786

Hello, I can see this is still open and It occurs in my code on the latest version of vue as well, I want to understand your comment, which says it is already fixed by other ticket. Is there some action needed to fix this?

@johnsoncodehk
Copy link
Member

It will fix in Vue 3.5 via vuejs/core#10801.

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 upstream
Projects
None yet
5 participants