This repository was archived by the owner on Jun 28, 2026. It is now read-only.
fix(datatable,datepicker,paginator): enable generic type inference for T, F, V, and PS - #8444
Open
YevheniiKotyrlo wants to merge 3 commits into
Open
fix(datatable,datepicker,paginator): enable generic type inference for T, F, V, and PS#8444YevheniiKotyrlo wants to merge 3 commits into
YevheniiKotyrlo wants to merge 3 commits into
Conversation
YevheniiKotyrlo
force-pushed
the
fix/generic-type-inference
branch
from
March 4, 2026 18:23
59a73a0 to
20900af
Compare
This was referenced Mar 11, 2026
Open
Add a third generic parameter PS (page size) to DataTable and Paginator type definitions, enabling TypeScript to narrow rows/rowsPerPageOptions to specific configured values (e.g., 5 | 10 | 20 | 50) instead of plain number. The generic flows end-to-end: rowsPerPageOptions accepts readonly PS[], rows prop and events emit PS, and rowChangeCallback receives PS. Defaults to number for full backward compatibility.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable TypeScript to infer generic type parameters from template bindings for DataTable, DatePicker, and Paginator. This completes the work started in #7427 by switching component declarations from
DefineComponent(no-arg constructor) to generic constructors that accept props.Generic parameters added
T(row data):value#groupheader/#groupfooter/#expansionslots,rowClass/rowStylecallbacks,sortFieldautocompleteF(filters)v-model:filtersupdate:filtersemit — eliminates 5strictTemplateserrorsPS(page size):rows-per-page-optionsrowsprop,update:rowsemit, and page eventrowsfield narrowed to configured valuesV(model value)v-modelupdate:modelValueemit — eliminates 1strictTemplateserrorPS(page size):rows-per-page-optionsPageState, slots, and emitsAll generics default to their original types (
T = any,F = DataTableFilterMeta,PS = number,V = Date | ...), so this is fully backward compatible.How it works
PrimeVue's
DefineComponentuses a no-arg constructor (new ()), which prevents TypeScript from inferring generics from template bindings. vue-tsc already generatesnew DataTable({ value: data, ... })— but with the no-arg constructor, the props are ignored for inference.The fix replaces
DefineComponent<Props, Slots, Emits>with an explicit generic constructor:PS page-size generic flow
rowsPerPageOptionsnow acceptsreadonly PS[]. When consumers pass a const tuple like[5, 10, 20, 50] as const, TypeScript infersPS = 5 | 10 | 20 | 50and narrows:rowsprop toPS(only configured page sizes)update:rowsemit toPSDataTablePageEvent.rowstoPSrowChangeCallbackto(value: PS) => voidPageState.rowstoPSFiles changed
packages/primevue/src/datatable/DataTable.d.ts— T, F, PS generics on DataTablepackages/primevue/src/datepicker/DatePicker.d.ts— V generic on DatePickerpackages/primevue/src/paginator/Paginator.d.ts— PS generic on PaginatorRelated issues
Test plan
prettier --checkpasseseslint .passespnpm run build:libsucceeds, dist output includes all generics