Skip to content

WIP: generic type inference in table for core/external plugins without *_All or *_Internal types#6327

Open
riccardoperra wants to merge 5 commits into
betafrom
feat/types-generic
Open

WIP: generic type inference in table for core/external plugins without *_All or *_Internal types#6327
riccardoperra wants to merge 5 commits into
betafrom
feat/types-generic

Conversation

@riccardoperra

@riccardoperra riccardoperra commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Consolidated type definitions to consistently use the public table and column APIs across core and feature utilities.
    • Removed deprecated internal type exports and “all-features” typing variants (including internal table/column/options/state/column-def bases).
    • Updated feature typings to use feature-composed generics for stronger end-to-end type safety; runtime behavior remains unchanged.
  • Tests
    • Updated TypeScript fixtures, helpers, and mocks to align with the public table types, including declaration-emit coverage.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a6e6c54-3ccc-43db-af4e-0f895f757daf

📥 Commits

Reviewing files that changed from the base of the PR and between 3351f3e and d065ced.

📒 Files selected for processing (9)
  • packages/table-core/src/core/headers/coreHeadersFeature.utils.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
  • packages/table-core/src/features/row-expanding/rowExpandingFeature.utils.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/features/row-expanding/rowExpandingFeature.utils.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts

📝 Walkthrough

Walkthrough

This PR retypes table-core from internal *_Internal and *_All types to public Table and related public surfaces, updates feature generic contexts and internal casts, removes deprecated internal helper types, adjusts tests, and adds a local path alias in tsconfig.json.

Changes

Public Table typing migration

Layer / File(s) Summary
Foundational type surface
packages/table-core/src/types/*, packages/table-core/src/core/*Feature.ts, packages/table-core/src/features/stockFeatures.ts
Table_Internal, TableOptions_All, TableState_All, Column_Internal, and related broad helper types are removed or replaced, and TableFeature becomes generic over feature context.
Core table and instance wiring
packages/table-core/src/core/table/*, packages/table-core/src/core/cells/*, packages/table-core/src/core/columns/*, packages/table-core/src/core/headers/*, packages/table-core/src/core/rows/*, packages/table-core/src/utils.ts
Core constructors, table utilities, prototype assignment helpers, and supporting core types now accept the public Table type, with constructTable and option/state wiring adjusted to mutate through a typed table alias.
Column and header feature utilities
packages/table-core/src/features/column-*/*, packages/table-core/src/features/global-filtering/*
Column and header feature helpers for faceting, filtering, grouping, ordering, pinning, sizing, resizing, visibility, and global filtering are retyped to public Table and Column surfaces and use feature-scoped casts for atoms and options.
Row model pipeline and row features
packages/table-core/src/core/row-models/*, packages/table-core/src/features/row-*/*
Row model creation and lookup, plus sorting, expansion, pagination, pinning, and selection helpers, are retyped to public Table and use feature-scoped table casts for cached factories, atoms, options, and reset paths.
Tests and project wiring
packages/table-core/tests/*, packages/table-core/tsconfig.json
Test helpers and type assertions are updated to the public Table type, and tsconfig.json adds a local package path alias.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

Possibly related PRs

  • TanStack/table#6320: Both PRs are TypeScript-type work in table-core centered on Table vs Table_Internal typing and related table utilities.
  • TanStack/table#6322: Both PRs update the same packages/table-core/src/types/* surfaces that the rest of the code compiles against.
  • TanStack/table#6299: Both PRs refactor the same feature-map-driven typing system and related public type contracts.

Suggested reviewers

  • KevinVandy

Poem

🐇 I nibbled the private types away,
And left the public paths to stay.
Tables hop with cleaner names,
Through rows and columns, typed in frames.
A burrow tidier than before—
Soft paws, strong generics, and a little more.

✨ 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 feat/types-generic

@nx-cloud

nx-cloud Bot commented Jun 15, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit d065ced

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

☁️ Nx Cloud last updated this comment at 2026-06-15 20:00:23 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-table

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

@tanstack/angular-table-devtools

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

@tanstack/lit-table

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

@tanstack/match-sorter-utils

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

@tanstack/preact-table

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

@tanstack/preact-table-devtools

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

@tanstack/react-table

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

@tanstack/react-table-devtools

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

@tanstack/solid-table

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

@tanstack/solid-table-devtools

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

@tanstack/svelte-table

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

@tanstack/table-core

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

@tanstack/table-devtools

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

@tanstack/vue-table

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

@tanstack/vue-table-devtools

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

commit: d065ced

nx-cloud[bot]

This comment was marked as outdated.

@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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts (1)

205-221: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Filtered/grouped selected row-model helpers are reading the wrong source model.

On Line 210 and Line 239, both helpers use table.getCoreRowModel(), which bypasses the pipeline stage implied by each API (filtered / grouped). This returns incorrect selected-row projections for those views.

Suggested fix
 export function table_getFilteredSelectedRowModel<
@@
 >(table: Table<TFeatures, TData>) {
   const featureTable = table as unknown as Table<RowSelectionFeatures, TData>
-  const rowModel = table.getCoreRowModel()
+  const rowModel = table.getFilteredRowModel()
@@
 export function table_getGroupedSelectedRowModel<
@@
 >(table: Table<TFeatures, TData>) {
   const featureTable = table as unknown as Table<RowSelectionFeatures, TData>
-  const rowModel = table.getCoreRowModel()
+  const rowModel = table.getGroupedRowModel()

Also applies to: 234-250

🤖 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/features/row-selection/rowSelectionFeature.utils.ts`
around lines 205 - 221, The table_getFilteredSelectedRowModel function is using
table.getCoreRowModel() which bypasses filtering and returns the wrong row
projection. Replace the getCoreRowModel() call with getFilteredRowModel() to use
the properly filtered row model. Additionally, the same issue exists in the
corresponding grouped helper function (also applies around line 234-250) where
you should replace getCoreRowModel() with getGroupedRowModel() to use the
properly grouped row model instead.
packages/table-core/src/features/stockFeatures.ts (1)

17-32: ⚠️ Potential issue | 🟡 Minor

Use typeof rowSelectionFeature to match the typing pattern of all other features in the interface.

Line 30 uses the bare TableFeature type, losing the generic type parameter, while all other features (lines 18–29, 31) use the typeof <featureName> pattern. Change rowSelectionFeature: TableFeature to rowSelectionFeature: typeof rowSelectionFeature for consistency.

🤖 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/features/stockFeatures.ts` around lines 17 - 32, The
StockFeatures interface has an inconsistent typing pattern where
rowSelectionFeature uses the bare TableFeature type instead of the typeof
pattern used by all other feature properties. Change the type annotation for
rowSelectionFeature from TableFeature to typeof rowSelectionFeature to maintain
consistency with the pattern used for columnFacetingFeature,
columnFilteringFeature, columnGroupingFeature, columnOrderingFeature,
columnPinningFeature, columnResizingFeature, columnSizingFeature,
columnVisibilityFeature, globalFilteringFeature, rowExpandingFeature,
rowPaginationFeature, rowPinningFeature, and rowSortingFeature.
🧹 Nitpick comments (1)
packages/table-core/src/features/column-pinning/columnPinningFeature.utils.ts (1)

791-796: ⚡ Quick win

Align table_getPinnedLeafColumns signature with documented behavior.

At Line 794, the type excludes false, but the docs and Line 795 branch explicitly handle falsy input (“all leaf columns”). Please make the signature match the supported behavior (or remove the branch/doc claim).

Suggested fix
-export function table_getPinnedLeafColumns<
+export function table_getPinnedLeafColumns<
   TFeatures extends TableFeatures,
   TData extends RowData,
->(table: Table<TFeatures, TData>, position: ColumnPinningPosition | 'center') {
+>(
+  table: Table<TFeatures, TData>,
+  position?: ColumnPinningPosition | 'center' | false,
+) {
🤖 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/features/column-pinning/columnPinningFeature.utils.ts`
around lines 791 - 796, The type signature of the position parameter in the
function table_getPinnedLeafColumns excludes false, but the implementation
checks !position (line 795) to handle the falsy case and return all leaf
columns. Update the position parameter type to include false or the appropriate
falsy value type to align the signature with the actual implementation that
handles falsy input, ensuring the documented behavior matches the type contract.
🤖 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 `@packages/table-core/src/features/column-faceting/columnFacetingFeature.ts`:
- Around line 16-20: The ColumnFacetingFeature type definition at lines 16-20
requires all three feature properties (columnFacetingFeature,
columnFilteringFeature, and globalFilteringFeature) to be present, which
over-constrains the feature inference when used in TableFeature at line 25. Fix
this by making the ColumnFacetingFeature type use Partial to make all properties
optional, allowing plugins to compose features flexibly without forcing
unrelated feature keys to exist in the feature set. This change at the type
definition will automatically resolve the over-constraining issue at the usage
site on line 25.

In `@packages/table-core/src/features/global-filtering/globalFilteringFeature.ts`:
- Line 30: Remove the explicit `any` type annotation from the `column` parameter
in the `getColumnCanGlobalFilter` callback. Instead of specifying `(column:
any)`, change it to `(column)` to allow TypeScript to properly infer the type as
`Column<TFeatures, TData, TValue>` from the interface contract, which will
preserve type information and enable better generic inference.

In `@packages/table-core/src/features/row-pagination/createPaginatedRowModel.ts`:
- Around line 33-38: The memoDeps array in the createPaginatedRowModel function
only tracks atoms.expanded when paginateExpandedRows is true, but the pagination
logic at line 69 applies expandRows after slicing regardless of the
paginateExpandedRows setting, meaning expanded state changes affect the result
even when paginateExpandedRows is false. Fix this by unconditionally including
featureTable.atoms.expanded?.get() in the memoDeps array instead of
conditionally adding it only when paginateExpandedRows is true, ensuring the
memoized pagination result is invalidated whenever the expanded state changes.

In `@packages/table-core/src/features/row-sorting/createSortedRowModel.ts`:
- Around line 60-62: The unsafe cast on line 61 in the sorting filter casts the
result of table.getColumn(sort.id) to Column before checking if it actually
exists, which causes column_getCanSort to receive undefined if the sort.id
references a missing column. Fix this by first checking that
table.getColumn(sort.id) returns a defined column before casting and passing it
to column_getCanSort. Add a null/undefined check within the filter predicate to
ensure the column exists before both the cast and the function call.

---

Outside diff comments:
In `@packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts`:
- Around line 205-221: The table_getFilteredSelectedRowModel function is using
table.getCoreRowModel() which bypasses filtering and returns the wrong row
projection. Replace the getCoreRowModel() call with getFilteredRowModel() to use
the properly filtered row model. Additionally, the same issue exists in the
corresponding grouped helper function (also applies around line 234-250) where
you should replace getCoreRowModel() with getGroupedRowModel() to use the
properly grouped row model instead.

In `@packages/table-core/src/features/stockFeatures.ts`:
- Around line 17-32: The StockFeatures interface has an inconsistent typing
pattern where rowSelectionFeature uses the bare TableFeature type instead of the
typeof pattern used by all other feature properties. Change the type annotation
for rowSelectionFeature from TableFeature to typeof rowSelectionFeature to
maintain consistency with the pattern used for columnFacetingFeature,
columnFilteringFeature, columnGroupingFeature, columnOrderingFeature,
columnPinningFeature, columnResizingFeature, columnSizingFeature,
columnVisibilityFeature, globalFilteringFeature, rowExpandingFeature,
rowPaginationFeature, rowPinningFeature, and rowSortingFeature.

---

Nitpick comments:
In
`@packages/table-core/src/features/column-pinning/columnPinningFeature.utils.ts`:
- Around line 791-796: The type signature of the position parameter in the
function table_getPinnedLeafColumns excludes false, but the implementation
checks !position (line 795) to handle the falsy case and return all leaf
columns. Update the position parameter type to include false or the appropriate
falsy value type to align the signature with the actual implementation that
handles falsy input, ensuring the documented behavior matches the type contract.
🪄 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: 40a4db68-bf26-4fcd-8d8d-34d79fc15320

📥 Commits

Reviewing files that changed from the base of the PR and between 26fc105 and 1872cf4.

📒 Files selected for processing (67)
  • packages/table-core/src/core/cells/constructCell.ts
  • packages/table-core/src/core/cells/coreCellsFeature.types.ts
  • packages/table-core/src/core/columns/constructColumn.ts
  • packages/table-core/src/core/columns/coreColumnsFeature.ts
  • packages/table-core/src/core/columns/coreColumnsFeature.types.ts
  • packages/table-core/src/core/columns/coreColumnsFeature.utils.ts
  • packages/table-core/src/core/headers/buildHeaderGroups.ts
  • packages/table-core/src/core/headers/constructHeader.ts
  • packages/table-core/src/core/headers/coreHeadersFeature.ts
  • packages/table-core/src/core/headers/coreHeadersFeature.utils.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts
  • packages/table-core/src/core/row-models/createCoreRowModel.ts
  • packages/table-core/src/core/rows/constructRow.ts
  • packages/table-core/src/core/rows/coreRowsFeature.ts
  • packages/table-core/src/core/rows/coreRowsFeature.types.ts
  • packages/table-core/src/core/rows/coreRowsFeature.utils.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/core/table/coreTablesFeature.types.ts
  • packages/table-core/src/core/table/coreTablesFeature.utils.ts
  • packages/table-core/src/features/column-faceting/columnFacetingFeature.ts
  • packages/table-core/src/features/column-faceting/columnFacetingFeature.utils.ts
  • packages/table-core/src/features/column-faceting/createFacetedMinMaxValues.ts
  • packages/table-core/src/features/column-faceting/createFacetedRowModel.ts
  • packages/table-core/src/features/column-faceting/createFacetedUniqueValues.ts
  • packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts
  • packages/table-core/src/features/column-filtering/createFilteredRowModel.ts
  • packages/table-core/src/features/column-filtering/filterRowsUtils.ts
  • packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/features/column-ordering/columnOrderingFeature.utils.ts
  • packages/table-core/src/features/column-pinning/columnPinningFeature.utils.ts
  • packages/table-core/src/features/column-resizing/columnResizingFeature.utils.ts
  • packages/table-core/src/features/column-sizing/columnSizingFeature.utils.ts
  • packages/table-core/src/features/column-visibility/columnVisibilityFeature.utils.ts
  • packages/table-core/src/features/global-filtering/globalFilteringFeature.ts
  • packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts
  • packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
  • packages/table-core/src/features/row-expanding/rowExpandingFeature.utils.ts
  • packages/table-core/src/features/row-pagination/createPaginatedRowModel.ts
  • packages/table-core/src/features/row-pagination/rowPaginationFeature.utils.ts
  • packages/table-core/src/features/row-pinning/rowPinningFeature.utils.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.types.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/src/features/row-sorting/createSortedRowModel.ts
  • packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts
  • packages/table-core/src/features/stockFeatures.ts
  • packages/table-core/src/types/Column.ts
  • packages/table-core/src/types/ColumnDef.ts
  • packages/table-core/src/types/RowModel.ts
  • packages/table-core/src/types/RowModelFns.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
  • packages/table-core/src/types/TableOptions.ts
  • packages/table-core/src/types/TableState.ts
  • packages/table-core/src/utils.ts
  • packages/table-core/tests/declaration-emit/tableOptions.ts
  • packages/table-core/tests/helpers/generateTestTable.ts
  • packages/table-core/tests/helpers/rowPinningHelpers.ts
  • packages/table-core/tests/unit/core/cells/constructCell.test.ts
  • packages/table-core/tests/unit/core/columns/constructColumn.test.ts
  • packages/table-core/tests/unit/core/headers/constructHeader.test.ts
  • packages/table-core/tests/unit/core/rows/constructRow.test.ts
  • packages/table-core/tests/unit/core/tableAtoms.test.ts
  • packages/table-core/tests/unit/features/column-pinning/columnPinningFeature.utils.test.ts
  • packages/table-core/tsconfig.json
💤 Files with no reviewable changes (4)
  • packages/table-core/src/types/RowModelFns.ts
  • packages/table-core/src/types/ColumnDef.ts
  • packages/table-core/src/types/TableState.ts
  • packages/table-core/src/types/Column.ts

Comment on lines +16 to +20
type ColumnFacetingFeature = {
columnFacetingFeature: TableFeature
columnFilteringFeature: TableFeature
globalFilteringFeature: TableFeature
}

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 | 🟠 Major | ⚡ Quick win

Use a partial feature map here to avoid over-constraining plugin feature inference.

ColumnFacetingFeature is currently required at Line 16-20, so TableFeature<ColumnFacetingFeature> at Line 25 forces unrelated feature keys to exist in the feature set. That can break the intended “core/external plugin” generic inference path.

Suggested fix
-type ColumnFacetingFeature = {
+type ColumnFacetingFeature = Partial<{
   columnFacetingFeature: TableFeature
   columnFilteringFeature: TableFeature
   globalFilteringFeature: TableFeature
-}
+}>

Also applies to: 25-25

🤖 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/features/column-faceting/columnFacetingFeature.ts`
around lines 16 - 20, The ColumnFacetingFeature type definition at lines 16-20
requires all three feature properties (columnFacetingFeature,
columnFilteringFeature, and globalFilteringFeature) to be present, which
over-constrains the feature inference when used in TableFeature at line 25. Fix
this by making the ColumnFacetingFeature type use Partial to make all properties
optional, allowing plugins to compose features flexibly without forcing
unrelated feature keys to exist in the feature set. This change at the type
definition will automatically resolve the over-constraining issue at the usage
site on line 25.

onGlobalFilterChange: makeStateUpdater('globalFilter', table),
globalFilterFn: 'auto',
getColumnCanGlobalFilter: (column) => {
getColumnCanGlobalFilter: (column: any) => {

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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the declared callback type and compare implementations.
rg -n --type=ts -C3 '\bgetColumnCanGlobalFilter\b' packages/table-core/src/types packages/table-core/src/features

Repository: TanStack/table

Length of output: 3615


🏁 Script executed:

cat -n packages/table-core/src/features/global-filtering/globalFilteringFeature.types.ts | sed -n '45,55p'

Repository: TanStack/table

Length of output: 506


Remove explicit any type from getColumnCanGlobalFilter callback parameter.

The getColumnCanGlobalFilter option contract defines the callback parameter as Column<TFeatures, TData, TValue>, a properly typed generic. Using any discards this type information and weakens the generic inference that this PR improves. Remove the explicit type annotation to allow proper inference from the interface contract.

Suggested change
-      getColumnCanGlobalFilter: (column: any) => {
+      getColumnCanGlobalFilter: (column) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getColumnCanGlobalFilter: (column: any) => {
getColumnCanGlobalFilter: (column) => {
🤖 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/features/global-filtering/globalFilteringFeature.ts`
at line 30, Remove the explicit `any` type annotation from the `column`
parameter in the `getColumnCanGlobalFilter` callback. Instead of specifying
`(column: any)`, change it to `(column)` to allow TypeScript to properly infer
the type as `Column<TFeatures, TData, TValue>` from the interface contract,
which will preserve type information and enable better generic inference.

Comment on lines 33 to 38
memoDeps: () => [
table.getPrePaginatedRowModel(),
table.atoms.pagination?.get(),
table.options.paginateExpandedRows
? table.atoms.expanded?.get()
featureTable.atoms.pagination?.get(),
featureTable.options.paginateExpandedRows
? featureTable.atoms.expanded?.get()
: undefined,

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 | 🟠 Major | ⚡ Quick win

Fix stale pagination memo when paginateExpandedRows is false.

At Line 69, paginated output depends on expanded state when paginateExpandedRows is false (expandRows(...) is applied after slicing). But Lines 36–38 only track atoms.expanded when paginateExpandedRows is true, so expanded toggles can leave getPaginatedRowModel() stale.

Suggested fix
       memoDeps: () => [
         table.getPrePaginatedRowModel(),
         featureTable.atoms.pagination?.get(),
-        featureTable.options.paginateExpandedRows
+        !featureTable.options.paginateExpandedRows
           ? featureTable.atoms.expanded?.get()
           : undefined,
       ],

Also applies to: 69-75

🤖 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/features/row-pagination/createPaginatedRowModel.ts`
around lines 33 - 38, The memoDeps array in the createPaginatedRowModel function
only tracks atoms.expanded when paginateExpandedRows is true, but the pagination
logic at line 69 applies expandRows after slicing regardless of the
paginateExpandedRows setting, meaning expanded state changes affect the result
even when paginateExpandedRows is false. Fix this by unconditionally including
featureTable.atoms.expanded?.get() in the memoDeps array instead of
conditionally adding it only when paginateExpandedRows is true, ensuring the
memoized pagination result is invalidated whenever the expanded state changes.

Comment on lines 60 to 62
const availableSorting = sorting.filter((sort) =>
column_getCanSort(
table.getColumn(sort.id) as Column_Internal<TFeatures, TData>,
),
column_getCanSort(table.getColumn(sort.id) as Column<TFeatures, TData>),
)

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 | 🟠 Major | ⚡ Quick win

Unsafe cast can crash when sorting references a missing column.

On Line 61, table.getColumn(sort.id) is cast to Column before nullability is checked. If a stale/unknown sort.id exists, column_getCanSort can dereference undefined.

Suggested fix
-  const availableSorting = sorting.filter((sort) =>
-    column_getCanSort(table.getColumn(sort.id) as Column<TFeatures, TData>),
-  )
+  const availableSorting = sorting.filter((sort) => {
+    const column = table.getColumn(sort.id)
+    return column ? column_getCanSort(column) : false
+  })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const availableSorting = sorting.filter((sort) =>
column_getCanSort(
table.getColumn(sort.id) as Column_Internal<TFeatures, TData>,
),
column_getCanSort(table.getColumn(sort.id) as Column<TFeatures, TData>),
)
const availableSorting = sorting.filter((sort) => {
const column = table.getColumn(sort.id)
return column ? column_getCanSort(column) : false
})
🤖 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/features/row-sorting/createSortedRowModel.ts` around
lines 60 - 62, The unsafe cast on line 61 in the sorting filter casts the result
of table.getColumn(sort.id) to Column before checking if it actually exists,
which causes column_getCanSort to receive undefined if the sort.id references a
missing column. Fix this by first checking that table.getColumn(sort.id) returns
a defined column before casting and passing it to column_getCanSort. Add a
null/undefined check within the filter predicate to ensure the column exists
before both the cast and the function call.

nx-cloud[bot]

This comment was marked as outdated.

@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.

🧹 Nitpick comments (1)
packages/table-core/src/core/headers/coreHeadersFeature.utils.ts (1)

174-174: 💤 Low value

Consider aligning the assertion style for consistency.

Line 174 uses an explicit type assertion (as Header<...>), while line 200 uses a non-null assertion (!) when pushing to identically typed result arrays. If the type cast on line 174 is necessary due to headerGroups[i]!.headers containing an internal header variant, this is fine. However, if both could use non-null assertions, that would improve consistency and maintainability.

Also applies to: 200-200

🤖 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/core/headers/coreHeadersFeature.utils.ts` at line
174, The code uses inconsistent assertion styles when pushing to the result
array - one location uses an explicit type assertion with `as Header<TFeatures,
TData, unknown>` while another location uses a non-null assertion with `!`.
Align these to use the same assertion style for consistency and maintainability.
If the explicit type assertion is necessary because the source type differs from
the target type, retain it as is; otherwise, update both locations to
consistently use non-null assertions instead of the explicit type cast.
🤖 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.

Nitpick comments:
In `@packages/table-core/src/core/headers/coreHeadersFeature.utils.ts`:
- Line 174: The code uses inconsistent assertion styles when pushing to the
result array - one location uses an explicit type assertion with `as
Header<TFeatures, TData, unknown>` while another location uses a non-null
assertion with `!`. Align these to use the same assertion style for consistency
and maintainability. If the explicit type assertion is necessary because the
source type differs from the target type, retain it as is; otherwise, update
both locations to consistently use non-null assertions instead of the explicit
type cast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 086858f5-ddc5-40ce-a0db-3c47b1e7aeed

📥 Commits

Reviewing files that changed from the base of the PR and between 1872cf4 and 3351f3e.

📒 Files selected for processing (14)
  • packages/table-core/src/core/columns/coreColumnsFeature.ts
  • packages/table-core/src/core/headers/coreHeadersFeature.utils.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/features/column-faceting/columnFacetingFeature.ts
  • packages/table-core/src/features/column-faceting/createFacetedMinMaxValues.ts
  • packages/table-core/src/features/column-faceting/createFacetedRowModel.ts
  • packages/table-core/src/features/column-faceting/createFacetedUniqueValues.ts
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
  • packages/table-core/src/features/row-expanding/rowExpandingFeature.utils.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/table-core/src/features/column-faceting/createFacetedMinMaxValues.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • packages/table-core/src/features/column-faceting/columnFacetingFeature.ts
  • packages/table-core/src/features/column-faceting/createFacetedUniqueValues.ts
  • packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
  • packages/table-core/src/core/table/constructTable.ts
  • packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
  • packages/table-core/src/types/Table.ts
  • packages/table-core/src/types/TableFeatures.ts
  • packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts
  • packages/table-core/src/features/row-expanding/rowExpandingFeature.utils.ts
  • packages/table-core/src/features/row-selection/rowSelectionFeature.utils.ts
  • packages/table-core/src/features/column-faceting/createFacetedRowModel.ts

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We fixed three ESLint errors introduced by the PR's type refactoring: two @typescript-eslint/no-unnecessary-type-assertion violations where as Column<...> and as Array<Column<...>> casts became redundant after switching from Table_Internal to the public Table type, and one import/newline-after-import violation where a newly added type declaration was missing a blank line after the last import. These changes restore ESLint compliance without altering any runtime behavior.

Tip

We verified this fix by re-running @tanstack/table-core:test:eslint.

Suggested Fix changes
diff --git a/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts b/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts
index 48423337..c2f34a79 100644
--- a/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts
+++ b/packages/table-core/src/core/columns/coreColumnsFeature.utils.ts
@@ -212,7 +212,7 @@ export function table_getAllLeafColumns<
     table,
     'getOrderColumns',
     table_getOrderColumnsFn,
-  )(leafColumns) as Array<Column<TFeatures, TData, unknown>>
+  )(leafColumns)
 }
 
 /**
diff --git a/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts b/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
index 7c4e5617..fb5e21a9 100644
--- a/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
+++ b/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts
@@ -160,9 +160,7 @@ function _createGroupedRowModel<
             // Aggregate the values
             const column = table.getColumn(colId)
             const aggregateFn = column
-              ? column_getAggregationFn(
-                  column as Column<TFeatures, TData, unknown>,
-                )
+              ? column_getAggregationFn(column)
               : undefined
 
             if (!row._groupingValuesCache) row._groupingValuesCache = {}
diff --git a/packages/table-core/src/features/row-expanding/createExpandedRowModel.ts b/packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
index eb6ea9ec..9762baf4 100644
--- a/packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
+++ b/packages/table-core/src/features/row-expanding/createExpandedRowModel.ts
@@ -5,6 +5,7 @@ import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
 import type { Table } from '../../types/Table'
 import type { Row } from '../../types/Row'
 import type { RowData } from '../../types/type-utils'
+
 type ExpandedRowModelFeatures = Partial<{ rowExpandingFeature: TableFeature }>
 
 /**

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally m5Ok-vXiA

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

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