Skip to content

fix(orderlist,picklist): enable generic type inference for items and slots#8491

Open
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/orderlist-picklist-generics
Open

fix(orderlist,picklist): enable generic type inference for items and slots#8491
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/orderlist-picklist-generics

Conversation

@YevheniiKotyrlo
Copy link

@YevheniiKotyrlo YevheniiKotyrlo commented Mar 11, 2026

Defect Fixes

Fixes #8488

OrderList and PickList use any for their modelValue and slot scoped data. Unlike the Select family (#8484), these components' modelValue IS the full item array — there is no optionValue extraction. This means modelValue itself becomes T[] / T[][], providing end-to-end type safety from binding to slot.

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

<OrderList v-model="products">
  <template #option="{ option }">
    {{ option.naem }}
    <!-- No error — `option` is `any`, typo ships to production -->
  </template>
</OrderList>

After this fix, TypeScript infers T from the v-model binding and flows it to all slots:

<OrderList v-model="products">
  <template #option="{ option }">
    {{ option.naem }}
    <!-- TS2339: Property 'naem' does not exist on type 'Product' -->
  </template>
</OrderList>

Changes

  • OrderListProps<T = any>modelValue: T[], selection: T[]
  • OrderListSlots<T = any>item: T, option: T
  • PickListProps<T = any>modelValue: T[][], selection: T[][]
  • PickListSlots<T = any>item: T, option: T
  • Both: generic constructor replaces DefineComponent

Why modelValue becomes T[] here

In Select/MultiSelect (#8484), modelValue stays any because optionValue extracts a scalar — the value type differs from the option type. OrderList and PickList have no optionValue extraction. The items in modelValue ARE the option objects, so modelValue: T[] is correct and gives full round-trip type safety.

What gets typed

Slot/Prop Before After
OrderList modelValue any[] T[]
OrderList selection any[] T[]
OrderList #option / #item data any T
PickList modelValue any[][] T[][]
PickList selection any[][] T[][]
PickList #option / #item data any T

Scope / Impact

  • No breaking changes — backward compatible, T defaults to any
  • No runtime changes — types only (.d.ts files)
  • 2 components: OrderList, PickList

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 PASS

Series

This is part of 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 This PR
#8493 VirtualScroller, SelectButton, InputChips Open

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

…slots

Make OrderListProps/Slots and PickListProps/Slots generic on T, inferred
from the modelValue binding. Unlike Select family, modelValue IS the
full item array (no optionValue extraction), so modelValue becomes T[].
OrderList item/option slots get T, PickList item/option slots get T.
PickList modelValue is T[][] (source + target arrays).
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.

OrderList, PickList: modelValue generic type not inferred in slots

1 participant