fix(table-core): CoreOptions columns and data are readonly
When used as the type for a function parameter, readonly ensures that the parameter will not be mutated inside the function.
The columns and data array inputs are never modified by table-core. They should thus be marked as readonly to make this contract explicit. This allows developper to rely on the guarantee they can pass in static objects.
Here's an example where this is useful:
const Component = () => {
const { data } = useQuery({ ... })
const table = useReactTable({ data, ... })
In a case like this, data comes from the tanstack/query cache, and as such must be immutable. If useReactTable can guarantee that it won't modify the array we pass in, then we can pass data directly.
Summary by CodeRabbit
-
Refactor
- Table options now use readonly arrays. Both data and columns accept readonly arrays, and related getters return readonly arrays. This enforces immutability and improves type safety. If your code mutates these arrays or relies on mutable types, update it to create new arrays instead.
-
Documentation
- API docs updated to reflect readonly types for data and columns in the Table APIs.
View your CI Pipeline Execution ↗ for commit e6b7bbdf952510aedf531f8cfac0437e750453b0
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many --targets=build --exclude=examples/** |
✅ Succeeded | 29s | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-09-22 07:18:23 UTC
Walkthrough
Types for data and column collections are changed to readonly arrays across core options, internal helpers, and documentation. CoreInstance’s _getColumnDefs now returns a readonly array. No algorithmic or control-flow changes are introduced.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Public API: readonly arraysdocs/api/core/table.md, packages/table-core/src/core/table.ts |
Updated CoreOptions: data: TData[] -> readonly TData[], columns: ColumnDef<TData, any>[] -> readonly ColumnDef<TData, any>[]. Updated CoreInstance: _getColumnDefs(): ColumnDef<TData, unknown>[] -> readonly ColumnDef<TData, unknown>[]. Reflected in docs. |
Internal helpers: readonly parameterspackages/table-core/src/utils/getCoreRowModel.ts, packages/table-core/src/core/table.ts |
Adjusted helper parameters to accept readonly arrays (e.g., recurseColumns(columnDefs: readonly ColumnDef<...>[]), accessRows(originalRows: readonly TData[])). No logic changes. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
I nudge my paws through rows so neat,
Columns crisp, immutable treat.
Readonly fields, no nibble’s sway—
The table stands in structured array.
I hop, I sort, with gentle care,
A bunny’s oath: don’t mutate there. 🐇✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The title succinctly and accurately describes the primary change in the changeset—marking CoreOptions.columns and CoreOptions.data as readonly in table-core types—matches the modified files and PR objectives, and is concise and clear without noise. |
✨ Finishing touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
[!TIP]
👮 Agentic pre-merge checks are now available in preview!
Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
- Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
- Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.
Please see the documentation for more information.
Example:
reviews: pre_merge_checks: custom_checks: - name: "Undocumented Breaking Changes" mode: "warning" instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post.
Comment @coderabbitai help to get the list of available commands and usage tips.
More templates
- tanstack-table-example-angular-basic
- tanstack-table-example-angular-column-ordering
- tanstack-table-example-angular-column-pinning
- tanstack-table-example-angular-column-pinning-sticky
- tanstack-table-example-angular-column-resizing-performant
- tanstack-table-example-angular-column-visibility
- tanstack-table-example-angular-editable
- tanstack-table-example-angular-expanding
- tanstack-table-example-angular-filters
- tanstack-table-example-angular-grouping
- tanstack-table-example-angular-row-dnd
- tanstack-table-example-angular-row-selection
- tanstack-table-example-angular-row-selection-signal
- tanstack-table-example-angular-signal-input
- tanstack-table-example-angular-sub-components
- tanstack-lit-table-example-basic
- tanstack-lit-table-example-column-sizing
- tanstack-lit-table-example-filters
- tanstack-lit-table-example-row-selection
- tanstack-lit-table-example-sorting
- tanstack-lit-table-example-sorting-dynamic-data
- tanstack-lit-table-virtualized-rows
- tanstack-table-example-qwik-basic
- tanstack-table-example-qwik-filters
- tanstack-table-example-qwik-row-selection
- tanstack-table-example-qwik-sorting
- tanstack-table-example-basic
- tanstack-table-example-bootstrap
- tanstack-table-example-column-dnd
- tanstack-table-example-column-groups
- tanstack-table-example-column-ordering
- tanstack-table-example-column-pinning
- tanstack-table-example-column-pinning-sticky
- tanstack-table-example-column-resizing-performant
- tanstack-table-example-column-sizing
- tanstack-table-example-column-visibility
- tanstack-table-example-custom-features
- tanstack-table-example-editable-data
- tanstack-table-example-expanding
- tanstack-table-example-filters
- tanstack-table-example-filters-faceted
- tanstack-table-example-filters-fuzzy
- tanstack-table-example-full-width-resizable-table
- tanstack-table-example-full-width
- tanstack-table-example-fully-controlled
- tanstack-table-example-grouping
- tanstack-table-example-kitchen-sink
- tanstack-table-example-material-ui-pagination
- tanstack-table-example-pagination
- tanstack-table-example-pagination-controlled
- tanstack-table-example-query-router-search-params
- tanstack-table-example-row-dnd
- tanstack-table-example-row-pinning
- tanstack-table-example-row-selection
- tanstack-table-example-sorting
- tanstack-table-example-sub-components
- tanstack-table-example-virtualized-columns
- tanstack-table-example-virtualized-columns-experimental
- tanstack-table-example-virtualized-infinite-scrolling
- tanstack-table-example-virtualized-rows
- tanstack-table-example-virtualized-rows-experimental
- tanstack-table-example-solid-basic
- tanstack-table-example-solid-bootstrap
- tanstack-table-example-solid-column-groups
- tanstack-table-example-solid-column-ordering
- tanstack-table-example-solid-column-visibility
- tanstack-table-example-solid-filters
- tanstack-table-example-solid-sorting
- tanstack-table-example-svelte-basic
- tanstack-table-example-svelte-column-groups
- tanstack-table-example-svelte-column-ordering
- tanstack-table-example-svelte-column-pinning
- tanstack-table-example-svelte-column-visibility
- tanstack-table-example-svelte-filtering
- tanstack-table-example-svelte-sorting
- tanstack-table-example-vanilla-basic
- tanstack-table-example-vanilla-pagination
- tanstack-table-example-vanilla-sorting
- tanstack-table-example-vue-basic
- tanstack-table-example-vue-column-ordering
- tanstack-table-example-vue-column-pinning
- tanstack-table-example-vue-filters
- tanstack-table-example-vue-grouping-rows
- tanstack-table-example-vue-pagination
- tanstack-table-example-vue-pagination-controlled
- tanstack-table-example-vue-row-selection
- tanstack-table-example-vue-sorting
- tanstack-table-example-vue-subcomponents
- tanstack-table-example-vue-virtualized-rows
@tanstack/angular-table
npm i https://pkg.pr.new/@tanstack/angular-table@6098
@tanstack/lit-table
npm i https://pkg.pr.new/@tanstack/lit-table@6098
@tanstack/match-sorter-utils
npm i https://pkg.pr.new/@tanstack/match-sorter-utils@6098
@tanstack/qwik-table
npm i https://pkg.pr.new/@tanstack/qwik-table@6098
@tanstack/react-table
npm i https://pkg.pr.new/@tanstack/react-table@6098
@tanstack/react-table-devtools
npm i https://pkg.pr.new/@tanstack/react-table-devtools@6098
@tanstack/solid-table
npm i https://pkg.pr.new/@tanstack/solid-table@6098
@tanstack/svelte-table
npm i https://pkg.pr.new/@tanstack/svelte-table@6098
@tanstack/table-core
npm i https://pkg.pr.new/@tanstack/table-core@6098
@tanstack/vue-table
npm i https://pkg.pr.new/@tanstack/vue-table@6098
commit: e6b7bbd