Skip to content

fix(virtualscroller,selectbutton,inputchips): enable generic type inference for items and slots#8493

Open
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/virtualscroller-selectbutton-inputchips-generics
Open

fix(virtualscroller,selectbutton,inputchips): enable generic type inference for items and slots#8493
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/virtualscroller-selectbutton-inputchips-generics

Conversation

@YevheniiKotyrlo
Copy link

@YevheniiKotyrlo YevheniiKotyrlo commented Mar 11, 2026

Defect Fixes

Fixes #8492

VirtualScroller, SelectButton, and InputChips use any for their collection props and slot scoped data. These are the last three PrimeVue components where collection props flow to slots without generic type inference.

Same root cause as #8442DefineComponent's no-arg constructor prevents generic inference. Same fix pattern as #8444 (DataTable/DatePicker).

Related: #7426, #6041

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

Problem

<SelectButton :options="cities" :optionLabel="(city) => city.name">
  <template #option="{ option }">
    {{ option.naem }}
    <!-- No error — `option` is `any`, typo ships to production -->
  </template>
</SelectButton>

After this fix, TypeScript infers T from the collection prop and flows it to all slots:

<SelectButton :options="cities" :optionLabel="(city) => city.name">
  <template #option="{ option }">
    {{ option.naem }}
    <!-- TS2339: Property 'naem' does not exist on type 'City' -->
  </template>
</SelectButton>

Changes

VirtualScroller:

  • VirtualScrollerProps<T = any>: items?: T[] | T[][]
  • VirtualScrollerSlots<T = any>: item slot item: T, content slot items: T[]

SelectButton:

InputChips:

Each component uses the generic constructor pattern (new <T>(props)) so TypeScript infers T automatically.

What gets typed

Slot/Callback Before After
VirtualScroller #item slot item any T
VirtualScroller #content slot items any T[]
SelectButton #option slot option any T
SelectButton optionLabel callback param any T
SelectButton optionValue callback param any T
SelectButton optionDisabled callback param any T
InputChips #chip slot value any T
InputChips modelValue any[] T[]

Scope / Impact

  • No breaking changes — backward compatible, T defaults to any
  • No runtime changes — types only (.d.ts files)
  • 3 components: VirtualScroller, SelectButton, InputChips

Verification

Gate Result
pnpm run format:check PASS
pnpm run lint PASS
pnpm run test:unit Pre-existing failures only, 0 new
pnpm run build:packages (primevue) PASS
Type pressure test (4 @ts-expect-error checks) PASS

Series

This is the final PR in a series bringing generic type inference to all PrimeVue data components:

PR Components Status
#8444 DataTable, DatePicker Open
#8484 Select, MultiSelect, Listbox Open
#8485 Column (phantom of prop) Open
#8489 AutoComplete, CascadeSelect, DataView Open
#8490 Carousel, Galleria, Timeline Open
#8491 OrderList, PickList Open
#8493 VirtualScroller, SelectButton, InputChips This PR

After this series, every PrimeVue component with a collection prop infers T from the binding and flows it to slots — giving developers full IDE autocomplete and compile-time type safety in templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant