Skip to content
Source
Sign inSign up
TanStack/table

fix(react-table): type aggregatedCell against bound cellComponents in createAppColumnHelper #6584

Closednirmal-shaji(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/6584/headopened

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 by tsc via test:types, excluded from the vitest run by its .test-d. name) asserting aggregatedCell accepts a bound component name across accessor / display / group, with a @ts-expect-error guard 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. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      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.tsx
      • packages/react-table/tests/createAppColumnHelper.test-d.tsx

      Included 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 aggregatedCell with bound cell components. New TypeScript tests validate this behavior for accessor, display, and group column helpers.

      Changes

      Aggregated cell typing

      Layer / File(s)Summary
      Aggregated cell column contracts
      packages/react-table/src/createTableHook.tsx
      The application column definition types omit the base aggregatedCell property and add an enhanced context. JSDoc now documents bound components in aggregated cell contexts.
      Aggregated cell type validation
      packages/react-table/tests/createAppColumnHelper.test-d.tsx
      Type-level tests verify registered components in aggregatedCell contexts and reject unregistered components for accessor, display, and group helpers.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Merge Risk: ⚪ Minimal · up to 3ff41

      Aggregated-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)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly describes the primary change: typing aggregatedCell against bound cellComponents in createAppColumnHelper.
      Description check✅ PassedThe description clearly explains the problem, cause, fix, scope, and test coverage. It does not use the template headings or include the checklist and release-impact sections, but the required technic…
      Linked Issues check✅ PassedThe PR satisfies issue #6583 by adding aggregatedCell to the omitted core keys and typing it with the enhanced cell context. The tests cover accessor, display, and group columns, including rejection…
      Out of Scope Changes check✅ PassedThe changes are limited to the requested type declarations, related JSDoc updates, and focused type-level tests. No unrelated runtime or product changes are present.
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.

Sign in to join this conversation.