Skip to content

Generic props are not handled properly in 3.x #6040

@spaceemotion

Description

@spaceemotion

Vue - Official extension or vue-tsc version

3.2.8 (checked from 3.2.2)

VSCode version

1.118.1

Vue version

3.5.22

TypeScript version

5.9.3 (also is a bug on 6.0.3)

Steps to reproduce

I have the following component:

<script setup lang="ts" generic="TGroup extends {}, TGroups extends Record<string, TGroup> = Record<string, TGroup>">

defineProps<{
  groups: TGroups;
}>();
</script>

<template>
  <div>
    <template
      v-if="Object.keys(groups).length > 0"
    >
      <template
        v-for="(group, type) of groups"
        :key="type"
      >
        <slot
          :group="group"
          :type="type"
        />
      </template>
    </template>

    <slot
      v-else
      name="empty"
    />
  </div>
</template>

What is expected?

When hovering over the group variable in the v-for (to inspect its type), it should be TGroup

What is actually happening?

Instead, group is marked as unknown.

Any additional comments?

This is not an issue with v2.2.12 - and one of the things preventing us from upgrading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good reproduction ✨This issue provides a good reproduction, we will be able to investigate it first🔨 p3-minor-bug

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions