Skip to content

feat: per table table and column meta#6316

Merged
KevinVandy merged 1 commit into
betafrom
better-meta
Jun 11, 2026
Merged

feat: per table table and column meta#6316
KevinVandy merged 1 commit into
betafrom
better-meta

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jun 11, 2026

Copy link
Copy Markdown
Member

🎯 Changes

no moar declaration merging required for table.options.meta or column meta

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

Summary by CodeRabbit

  • Documentation

    • Added comprehensive "Table and Column Meta" guide covering usage patterns across all frameworks.
    • Updated migration guides for Angular, React, Vue, Svelte, Preact, Solid, Lit clarifying TableMeta/ColumnMeta typing changes in v9.
    • Clarified that meta declaration merging is no longer required; introduced per-table meta typing approach as an alternative.
  • New Features

    • Introduced simplified meta typing option allowing type-safe metadata at the table level without global configuration.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces per-table/per-features meta typing to TanStack Table v9. Instead of requiring global TypeScript module augmentation for TableMeta and ColumnMeta, developers can now define typed meta interfaces locally and wire them into their table's features configuration using the new metaHelper utility and type-only phantom slots. The change maintains backward compatibility with global declaration merging while providing a scoped, composable alternative.

Changes

Core Type System and Runtime Implementation

Layer / File(s) Summary
Phantom Type Slots and Utility Export
packages/table-core/src/types/TableFeatures.ts, packages/table-core/src/helpers/metaHelper.ts, packages/table-core/src/index.ts, packages/table-core/src/helpers/tableFeatures.ts
Adds optional tableMeta and columnMeta type-only phantom slots to TableFeatures, exports the IsAny conditional type, introduces metaHelper<TMeta>() utility, and updates JSDoc examples showing per-table meta declaration.
Conditional Meta Type Extraction
packages/table-core/src/core/table/coreTablesFeature.types.ts, packages/table-core/src/types/ColumnDef.ts
Adds ExtractTableMeta and ExtractColumnMeta conditional types that prefer feature-scoped tableMeta/columnMeta slots over globally merged interfaces; updates TableOptions_Table.meta and ColumnDefBase_Core.meta property types to use these extractors.
Runtime Feature Stripping and Debug Options
packages/table-core/src/core/table/constructTable.ts, packages/table-core/src/types/TableOptions.ts
Strips tableMeta and columnMeta from internal feature sets during table construction; excludes these type-only slots from debug option key generation so they don't generate spurious debugTableMeta/debugColumnMeta flags.

Documentation and Migration Guides

Layer / File(s) Summary
Comprehensive Meta Guide
docs/guide/table-and-column-meta.md
New guide explaining table/column meta concepts, runtime access patterns, per-table type-safe approach with metaHelper, global declaration merging fallback, precedence rules between per-features and global types, and guidance on custom features vs. meta.
Framework-Specific Migration Guides
docs/framework/angular/guide/migrating.md, docs/framework/lit/guide/migrating.md, docs/framework/preact/guide/migrating.md, docs/framework/react/guide/migrating.md, docs/framework/solid/guide/migrating.md, docs/framework/svelte/guide/migrating.md, docs/framework/vue/guide/migrating.md
Updates all framework migration guides to clarify declaration merging is no longer required, document TFeatures as first generic parameter in module augmentation, and introduce per-table tableMeta/columnMeta slots with metaHelper as an alternative.
Navigation Configuration
docs/config.json
Adds link to new "Table and Column Meta" guide in Core Guides navigation.

Framework Examples

Layer / File(s) Summary
Angular Examples
examples/angular/editable/src/app/app.ts, examples/angular/filters/src/app/app.ts, examples/angular/filters-faceted/src/app/app.ts, examples/angular/filters/src/app/table-filter/table-filter.ts, examples/angular/filters-faceted/src/app/table-filter/table-filter.ts, examples/angular/kitchen-sink/src/app/app.ts
Replaces module augmentation with local MyTableMeta/MyColumnMeta interfaces and metaHelper wiring; removes global ColumnMeta declarations and updates all table/column type parameters to use custom features.
Lit Examples
examples/lit/filters/src/main.ts, examples/lit/kitchen-sink/src/main.ts
Introduces local MyColumnMeta with metaHelper, removes global ColumnMeta augmentation, and updates type annotations to use custom features instead of stockFeatures.
Preact Examples
examples/preact/filters/src/main.tsx, examples/preact/filters-faceted/src/main.tsx, examples/preact/kitchen-sink/src/main.tsx
Switches from global ColumnMeta augmentation to local MyColumnMeta with metaHelper; updates all component and filter function generics to reference custom features.
React Examples
examples/react/filters/src/main.tsx, examples/react/filters-faceted/src/main.tsx, examples/react/kitchen-sink-hero-ui/src/main.tsx, examples/react/kitchen-sink-mantine/src/main.tsx, examples/react/kitchen-sink-material-ui/src/main.tsx, examples/react/kitchen-sink-react-aria/src/main.tsx, examples/react/kitchen-sink-shadcn-base/src/main.tsx, examples/react/kitchen-sink-shadcn-radix/src/main.tsx, examples/react/kitchen-sink/src/main.tsx, examples/react/with-tanstack-router/src/components/table.tsx, examples/react/with-tanstack-router/src/utils/userColumns.tsx, examples/react/kitchen-sink-shadcn-base/src/components/data-table/data-table-filter-list.tsx, examples/react/kitchen-sink-shadcn-radix/src/components/data-table/data-table-filter-list.tsx
Removes global ColumnMeta augmentation across all React variants; replaces with local MyColumnMeta + metaHelper wiring; updates type parameters from stockFeatures to custom features.
Solid Examples
examples/solid/kitchen-sink/src/App.tsx, examples/solid/with-tanstack-router/src/components/table.tsx, examples/solid/with-tanstack-router/src/utils/userColumns.tsx
Removes ColumnMeta module augmentation; introduces local MyColumnMeta with metaHelper; updates filter input UI to use typed filterKey; switches all generics to features.
Svelte Examples
examples/svelte/kitchen-sink/src/App.svelte, examples/svelte/kitchen-sink/src/table-augmentations.ts
Removes ColumnMeta augmentation; uses local MyColumnMeta with metaHelper; updates type parameters across sorting, filtering, and styling helpers to use features.
Vue Examples
examples/vue/kitchen-sink/src/App.vue
Removes ColumnMeta augmentation; introduces local MyColumnMeta with metaHelper; updates module augmentation to target custom features for fuzzy filter; switches all component/helper generics.

Tests

Layer / File(s) Summary
Meta Type Slots Test Suite
packages/table-core/tests/unit/core/table/metaTypeSlots.test.ts
Comprehensive test covering runtime behavior (type-only slots are stripped from feature object), compile-time type inference (ExtractTableMeta/ExtractColumnMeta resolve to local types), exclusion of debug options for phantom slots, and fallback to global declaration-merged types when slots are omitted.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • TanStack/table#6268: Both PRs modify constructTable.ts, with the retrieved PR refactoring iteration logic while this PR strips type-only slots from feature construction.
  • TanStack/table#6305: The retrieved PR's feature/type refactors provide the foundation that this PR builds on with per-table meta typing.

Suggested Reviewers

  • schiller-manuel

Poem

🐰 Type slots drift where features play,
No global reach—per-table way!
Meta helpers, phantom, light,
Local types now held just right.
Five frameworks dance in sync once more,
Typed and tidy, examples pour. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: introducing per-table (feature-scoped) typing for table and column meta, eliminating the need for declaration merging.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch better-meta

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 23cc80a

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 2m 57s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 27s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-11 14:20:35 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6316

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6316

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6316

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6316

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6316

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6316

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6316

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6316

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6316

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6316

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6316

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6316

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6316

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6316

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6316

commit: 23cc80a

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
docs/framework/vue/guide/migrating.md (1)

572-572: ⚡ Quick win

Consider 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 ExtractTableMeta and ExtractColumnMeta logic), 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 win

Prefer metaHelper(...) in this JSDoc example for meta slots.

This example currently teaches direct {} as ... assertions (including an all-optional columnMeta shape), which is exactly the case metaHelper was 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e5ba41 and 23cc80a.

📒 Files selected for processing (48)
  • docs/config.json
  • docs/framework/angular/guide/migrating.md
  • docs/framework/lit/guide/migrating.md
  • docs/framework/preact/guide/migrating.md
  • docs/framework/react/guide/migrating.md
  • docs/framework/solid/guide/migrating.md
  • docs/framework/svelte/guide/migrating.md
  • docs/framework/vue/guide/migrating.md
  • docs/guide/table-and-column-meta.md
  • examples/angular/editable/src/app/app.ts
  • examples/angular/filters-faceted/src/app/app.ts
  • examples/angular/filters-faceted/src/app/table-filter/table-filter.ts
  • examples/angular/filters/src/app/app.ts
  • examples/angular/filters/src/app/table-filter/table-filter.ts
  • examples/angular/kitchen-sink/src/app/app.ts
  • examples/lit/filters/src/main.ts
  • examples/lit/kitchen-sink/src/main.ts
  • examples/preact/filters-faceted/src/main.tsx
  • examples/preact/filters/src/main.tsx
  • examples/preact/kitchen-sink/src/main.tsx
  • examples/react/filters-faceted/src/main.tsx
  • examples/react/filters/src/main.tsx
  • examples/react/kitchen-sink-hero-ui/src/main.tsx
  • examples/react/kitchen-sink-mantine/src/main.tsx
  • examples/react/kitchen-sink-material-ui/src/main.tsx
  • examples/react/kitchen-sink-react-aria/src/main.tsx
  • examples/react/kitchen-sink-shadcn-base/src/components/data-table/data-table-filter-list.tsx
  • examples/react/kitchen-sink-shadcn-base/src/main.tsx
  • examples/react/kitchen-sink-shadcn-radix/src/components/data-table/data-table-filter-list.tsx
  • examples/react/kitchen-sink-shadcn-radix/src/main.tsx
  • examples/react/kitchen-sink/src/main.tsx
  • examples/react/with-tanstack-router/src/components/table.tsx
  • examples/react/with-tanstack-router/src/utils/userColumns.tsx
  • examples/solid/kitchen-sink/src/App.tsx
  • examples/solid/with-tanstack-router/src/components/table.tsx
  • examples/solid/with-tanstack-router/src/utils/userColumns.tsx
  • examples/svelte/kitchen-sink/src/App.svelte
  • examples/svelte/kitchen-sink/src/table-augmentations.ts
  • examples/vue/kitchen-sink/src/App.vue
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/core/table/coreTablesFeature.types.ts
  • packages/table-core/src/helpers/metaHelper.ts
  • packages/table-core/src/helpers/tableFeatures.ts
  • packages/table-core/src/index.ts
  • packages/table-core/src/types/ColumnDef.ts
  • packages/table-core/src/types/TableFeatures.ts
  • packages/table-core/src/types/TableOptions.ts
  • packages/table-core/tests/unit/core/table/metaTypeSlots.test.ts
💤 Files with no reviewable changes (1)
  • examples/react/with-tanstack-router/src/utils/userColumns.tsx

Comment on lines +729 to +734
```ts
const features = tableFeatures({
rowSortingFeature,
columnMeta: metaHelper<{ customProperty: string }>(),
})
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Comment thread docs/framework/vue/guide/migrating.md
@KevinVandy KevinVandy merged commit 4108c59 into beta Jun 11, 2026
8 checks passed
@KevinVandy KevinVandy deleted the better-meta branch June 11, 2026 14:38
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.

1 participant