fix(react-table): type aggregatedCell against bound cellComponents in createAppColumnHelper #6584
main fromrefs/pull/6584/head·opened Problem#
createAppColumnHelper (from createTableHook) returns column-definition types whose render props are enhanced with the registered cellComponents / headerComponents, so you can write cell: ({ cell }) => <cell.MyCell />. This worked for cell, header, and footer, but not for aggregatedCell: inside it the cell render prop was the plain core Cell, with no bound components, so ({ cell }) => <cell.MyCell /> was a type error.
Fixes #6583
Cause#
AppColumnDefBase (and its siblings AppDisplayColumnDef / AppGroupColumnDef) Omit the core cell | header | footer keys and re-declare them against the enhanced AppCellContext / AppHeaderContext. aggregatedCell — contributed by rowAggregationFeature and typed against the cell context, exactly like cell — was never part of that omit-and-enhance set, so it retained its core type.
Fix#
Add 'aggregatedCell' to the omitted keys and re-declare it mirroring cell (both share the cell context) in AppColumnDefBase, AppDisplayColumnDef, and AppGroupColumnDef. This is a type-only, localized change; the runtime column helper is untouched (components are still bound at render time). JSDoc that enumerates the bound contexts was updated to mention aggregatedCell.
Testing#
- Added
packages/react-table/tests/createAppColumnHelper.test-d.tsx, a type-level test (checked bytscviatest:types, excluded from the vitest run by its.test-d.name) assertingaggregatedCellaccepts a bound component name acrossaccessor/display/group, with a@ts-expect-errorguard that an unregistered component is still rejected. Confirmed it fails before the fix and passes after. pnpm --filter @tanstack/react-table test:types→ passes.pnpm --filter @tanstack/react-table test:lib→ 6 files, 34 tests passing.- ESLint on the changed files → clean.
Summary by CodeRabbit#
New Features
- Added support for custom rendering of aggregated cell values across accessor, display, and group columns.
- Registered cell components are now available when rendering aggregated cells, with type checking to prevent unsupported components.
Tests
- Added type-level coverage validating aggregated-cell rendering and component registration across column helpers.
- 1
nirmal-shaji(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
1f2d1d39-59c6-4a12-8363-c8143ce2138d📥 Commits
Reviewing files that changed from the base of the PR and between 36733a38b6a77878eea616b25012c47a0f93d4da and 3ff41332caa435adeab8504b91a18eed9a6ff687.
📒 Files selected for processing (2)
packages/react-table/src/createTableHook.tsxpackages/react-table/tests/createAppColumnHelper.test-d.tsxIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The React Table column definition types now support
aggregatedCellwith bound cell components. New TypeScript tests validate this behavior for accessor, display, and group column helpers.Changes#
Aggregated cell typing
packages/react-table/src/createTableHook.tsxaggregatedCellproperty and add an enhanced context. JSDoc now documents bound components in aggregated cell contexts.packages/react-table/tests/createAppColumnHelper.test-d.tsxaggregatedCellcontexts and reject unregistered components for accessor, display, and group helpers.Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
3ff41Aggregated-cell render props now expose registered cell components consistently with other column render props, resolving the TypeScript limitation without changing runtime behavior. No current merge-blocking risk remains.
Suggested reviewers:
kevinvandy🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
aggregatedCellagainst boundcellComponentsincreateAppColumnHelper.#6583by addingaggregatedCellto the omitted core keys and typing it with the enhanced cell context. The tests cover accessor, display, and group columns, including rejection…✨ Finishing Touches
🧪 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.
❤️ Share