-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
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
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, SelectButtonoptions, or InputChipsmodelValue - Use the
#item,#option, or#chipslot - The slot parameter is typed as
anyinstead 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels