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: StackBlitz — bun 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
- Pass a typed array to VirtualScroller
items, SelectButton options, or InputChips modelValue
- Use the
#item, #option, or #chip slot
- 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.
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:
SelectButton:
InputChips:
Reproducer: StackBlitz —
bun 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
items, SelectButtonoptions, or InputChipsmodelValue#item,#option, or#chipslotanyinstead of the array element typeExpected behavior
TypeScript should infer the generic type
Tfrom the collection prop and propagate it to slot parameters and callback arguments, providing full type safety without explicit annotations.