feat: per table table and column meta#6316
Conversation
📝 WalkthroughWalkthroughThis PR introduces per-table/per-features meta typing to TanStack Table v9. Instead of requiring global TypeScript module augmentation for ChangesCore Type System and Runtime Implementation
Documentation and Migration Guides
Framework Examples
Tests
🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 23cc80a
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
docs/framework/vue/guide/migrating.md (1)
572-572: ⚡ Quick winConsider clarifying the declaration merging statement.
The phrase "No more declaration merging required!" might briefly mislead readers into thinking declaration merging no longer works or is deprecated. Since declaration merging remains the fallback mechanism when per-table meta slots are absent (per
ExtractTableMetaandExtractColumnMetalogic), consider rephrasing to: "Declaration merging is now optional!" or "Per-table meta typing eliminates the need for declaration merging."The parenthetical clarification helps, but tightening the opening statement would improve accuracy.
📝 Suggested rewording
-No more declaration merging required! (Although it still works if you want to keep using it) +Declaration merging is now optional! (It still works as a fallback if you prefer global meta types)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/framework/vue/guide/migrating.md` at line 572, The sentence "No more declaration merging required!" is potentially misleading; update the wording to clarify that declaration merging is still supported but optional now that per-table meta typing (see ExtractTableMeta and ExtractColumnMeta) handles typing when per-table meta slots are present—for example rephrase to "Declaration merging is now optional!" or "Per-table meta typing eliminates the need for declaration merging." Keep the parenthetical note "(Although it still works if you want to keep using it)" or merge it into the revised sentence for clarity.packages/table-core/src/helpers/tableFeatures.ts (1)
8-20: ⚡ Quick winPrefer
metaHelper(...)in this JSDoc example for meta slots.This example currently teaches direct
{} as ...assertions (including an all-optionalcolumnMetashape), which is exactly the casemetaHelperwas added to make safer and clearer.Suggested doc example update
- * import { tableFeatures, columnVisibilityFeature, rowPinningFeature } from '`@tanstack/react-table`' + * import { metaHelper, tableFeatures, columnVisibilityFeature, rowPinningFeature } from '`@tanstack/react-table`' * const features = tableFeatures({ * columnVisibilityFeature, * rowPinningFeature, - * tableMeta: {} as { updateData: (rowIndex: number, columnId: string, value: unknown) => void }, - * columnMeta: {} as { align?: 'left' | 'right' }, + * tableMeta: metaHelper<{ updateData: (rowIndex: number, columnId: string, value: unknown) => void }>(), + * columnMeta: metaHelper<{ align?: 'left' | 'right' }>(), * });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/table-core/src/helpers/tableFeatures.ts` around lines 8 - 20, Update the JSDoc example in tableFeatures to use the metaHelper helper instead of inline type assertions; replace the `tableMeta: {} as ...` and `columnMeta: {} as ...` usages with calls to `metaHelper(...)` so the example shows `tableFeatures({ columnVisibilityFeature, rowPinningFeature, tableMeta: metaHelper<...>(), columnMeta: metaHelper<...>() })` (referencing the tableFeatures, columnVisibilityFeature, rowPinningFeature and metaHelper symbols) to demonstrate the safer, clearer pattern introduced for meta slots.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/framework/angular/guide/migrating.md`:
- Around line 729-734: The snippet uses metaHelper but doesn't show its import;
update the migration example so metaHelper is explicitly imported alongside
tableFeatures and rowSortingFeature (or mark the snippet as non-standalone).
Specifically, ensure the import list in the example includes metaHelper (the
helper used for columnMeta) so the shown code using tableFeatures,
rowSortingFeature, and metaHelper<{ customProperty: string }>() compiles when
copy/pasted.
In `@docs/framework/vue/guide/migrating.md`:
- Around line 588-593: Add the missing import for metaHelper so the example is
copy-pastable: update the example to import metaHelper along with tableFeatures
and rowSortingFeature (symbols: metaHelper, tableFeatures, rowSortingFeature)
from the same package used in the guide, then leave the rest of the snippet
as-is.
---
Nitpick comments:
In `@docs/framework/vue/guide/migrating.md`:
- Line 572: The sentence "No more declaration merging required!" is potentially
misleading; update the wording to clarify that declaration merging is still
supported but optional now that per-table meta typing (see ExtractTableMeta and
ExtractColumnMeta) handles typing when per-table meta slots are present—for
example rephrase to "Declaration merging is now optional!" or "Per-table meta
typing eliminates the need for declaration merging." Keep the parenthetical note
"(Although it still works if you want to keep using it)" or merge it into the
revised sentence for clarity.
In `@packages/table-core/src/helpers/tableFeatures.ts`:
- Around line 8-20: Update the JSDoc example in tableFeatures to use the
metaHelper helper instead of inline type assertions; replace the `tableMeta: {}
as ...` and `columnMeta: {} as ...` usages with calls to `metaHelper(...)` so
the example shows `tableFeatures({ columnVisibilityFeature, rowPinningFeature,
tableMeta: metaHelper<...>(), columnMeta: metaHelper<...>() })` (referencing the
tableFeatures, columnVisibilityFeature, rowPinningFeature and metaHelper
symbols) to demonstrate the safer, clearer pattern introduced for meta slots.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 19197b9b-5ee6-492c-bfe1-54de1bd6cd88
📒 Files selected for processing (48)
docs/config.jsondocs/framework/angular/guide/migrating.mddocs/framework/lit/guide/migrating.mddocs/framework/preact/guide/migrating.mddocs/framework/react/guide/migrating.mddocs/framework/solid/guide/migrating.mddocs/framework/svelte/guide/migrating.mddocs/framework/vue/guide/migrating.mddocs/guide/table-and-column-meta.mdexamples/angular/editable/src/app/app.tsexamples/angular/filters-faceted/src/app/app.tsexamples/angular/filters-faceted/src/app/table-filter/table-filter.tsexamples/angular/filters/src/app/app.tsexamples/angular/filters/src/app/table-filter/table-filter.tsexamples/angular/kitchen-sink/src/app/app.tsexamples/lit/filters/src/main.tsexamples/lit/kitchen-sink/src/main.tsexamples/preact/filters-faceted/src/main.tsxexamples/preact/filters/src/main.tsxexamples/preact/kitchen-sink/src/main.tsxexamples/react/filters-faceted/src/main.tsxexamples/react/filters/src/main.tsxexamples/react/kitchen-sink-hero-ui/src/main.tsxexamples/react/kitchen-sink-mantine/src/main.tsxexamples/react/kitchen-sink-material-ui/src/main.tsxexamples/react/kitchen-sink-react-aria/src/main.tsxexamples/react/kitchen-sink-shadcn-base/src/components/data-table/data-table-filter-list.tsxexamples/react/kitchen-sink-shadcn-base/src/main.tsxexamples/react/kitchen-sink-shadcn-radix/src/components/data-table/data-table-filter-list.tsxexamples/react/kitchen-sink-shadcn-radix/src/main.tsxexamples/react/kitchen-sink/src/main.tsxexamples/react/with-tanstack-router/src/components/table.tsxexamples/react/with-tanstack-router/src/utils/userColumns.tsxexamples/solid/kitchen-sink/src/App.tsxexamples/solid/with-tanstack-router/src/components/table.tsxexamples/solid/with-tanstack-router/src/utils/userColumns.tsxexamples/svelte/kitchen-sink/src/App.svelteexamples/svelte/kitchen-sink/src/table-augmentations.tsexamples/vue/kitchen-sink/src/App.vuepackages/table-core/src/core/table/constructTable.tspackages/table-core/src/core/table/coreTablesFeature.types.tspackages/table-core/src/helpers/metaHelper.tspackages/table-core/src/helpers/tableFeatures.tspackages/table-core/src/index.tspackages/table-core/src/types/ColumnDef.tspackages/table-core/src/types/TableFeatures.tspackages/table-core/src/types/TableOptions.tspackages/table-core/tests/unit/core/table/metaTypeSlots.test.ts
💤 Files with no reviewable changes (1)
- examples/react/with-tanstack-router/src/utils/userColumns.tsx
| ```ts | ||
| const features = tableFeatures({ | ||
| rowSortingFeature, | ||
| columnMeta: metaHelper<{ customProperty: string }>(), | ||
| }) | ||
| ``` |
There was a problem hiding this comment.
Shared root cause: per-table meta snippets use metaHelper without an explicit import in-framework.
Please align these migration snippets by showing metaHelper in the import list (or making each snippet explicitly non-standalone) so copy/paste paths compile consistently across adapters.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/framework/angular/guide/migrating.md` around lines 729 - 734, The
snippet uses metaHelper but doesn't show its import; update the migration
example so metaHelper is explicitly imported alongside tableFeatures and
rowSortingFeature (or mark the snippet as non-standalone). Specifically, ensure
the import list in the example includes metaHelper (the helper used for
columnMeta) so the shown code using tableFeatures, rowSortingFeature, and
metaHelper<{ customProperty: string }>() compiles when copy/pasted.
🎯 Changes
no moar declaration merging required for table.options.meta or column meta
✅ Checklist
pnpm test:pr.Summary by CodeRabbit
Documentation
New Features