Skip to content

fix(carousel,galleria,timeline): enable generic type inference for value and slots#8490

Open
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/carousel-galleria-timeline-generics
Open

fix(carousel,galleria,timeline): enable generic type inference for value and slots#8490
YevheniiKotyrlo wants to merge 1 commit intoprimefaces:masterfrom
YevheniiKotyrlo:fix/carousel-galleria-timeline-generics

Conversation

@YevheniiKotyrlo
Copy link

@YevheniiKotyrlo YevheniiKotyrlo commented Mar 11, 2026

Defect Fixes

Fixes #8487

Carousel, Galleria, and Timeline use any for their value arrays and slot scoped data. Developers get no IDE autocomplete and no compile-time safety when rendering items in these data-display components.

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

<Carousel :value="products">
  <template #item="{ data }">
    {{ data.naem }}
    <!-- No error — `data` is `any`, typo ships to production -->
  </template>
</Carousel>

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

<Carousel :value="products">
  <template #item="{ data }">
    {{ data.naem }}
    <!-- TS2339: Property 'naem' does not exist on type 'Product' -->
  </template>
</Carousel>

Changes

For each component:

  • [Component]Props<T = any>value: T[]
  • [Component]Slots<T = any> — all data-bearing slot parameters become T
  • Generic constructor: new <T = any>(props: [Component]Props<T>) with $slots: [Component]Slots<T>

What gets typed

Slot Before After
Carousel #item data any T
Galleria #item / #caption / #thumbnail item any T
Timeline #content / #opposite / #marker / #connector item any T

Scope / Impact

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

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 This PR
#8491 OrderList, PickList Open
#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.

…lue and slots

Make CarouselProps/Slots, GalleriaProps/Slots, and TimelineProps/Slots
generic on T, inferred from the value binding.
Replace DefineComponent with generic constructors for type inference.
Carousel item slot data, Galleria item/caption/thumbnail slots,
and Timeline content/opposite/marker/connector slots all become T.
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.

Carousel, Galleria, Timeline: value generic type not inferred in slots

1 participant