Skip to content

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

Closed
@LinusBorg

Description

@LinusBorg
<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=

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions