Skip to content

VirtualScroller, SelectButton, InputChips: generic type not inferred from items/options/modelValue #8492

@YevheniiKotyrlo

Description

@YevheniiKotyrlo

Describe the bug

When using VirtualScroller, SelectButton, or InputChips with typed collections, TypeScript cannot infer the item/option type in slots and callbacks. Slot parameters and callback arguments remain typed as any, losing type safety.

VirtualScroller:

<VirtualScroller :items="products">
  <template #item="{ item }">
    <!-- item is any, should be Product -->
    {{ item.name }}
  </template>
</VirtualScroller>

SelectButton:

<SelectButton
  :options="cities"
  :option-label="(city) => city.name"
>
  <!-- city parameter is any, should be City -->
  <template #option="{ option }">
    <!-- option is any, should be City -->
    {{ option.name }}
  </template>
</SelectButton>

InputChips:

<InputChips :model-value="tags">
  <template #chip="{ value }">
    <!-- value is any, should be Tag -->
    {{ value.label }}
  </template>
</InputChips>

Reproducer: StackBlitzbun run type-check (0 errors, typo undetected) → bun run patch && bun run type-check (TS2339 catches it)

Reproducer

https://stackblitz.com/github/YevheniiKotyrlo/primevue-generic-type-repro?file=src%2FApp.vue

Pull Request Link

#8493

PrimeVue version

4.5.4

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

N/A (type-level issue)

Steps to reproduce the behavior

  1. Pass a typed array to VirtualScroller items, SelectButton options, or InputChips modelValue
  2. Use the #item, #option, or #chip slot
  3. The slot parameter is typed as any instead of the array element type

Expected behavior

TypeScript should infer the generic type T from the collection prop and propagate it to slot parameters and callback arguments, providing full type safety without explicit annotations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions