Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(table-core): CoreOptions columns and data are readonly#6098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Sheraff wants to merge2 commits intoTanStack:main
base:main
Choose a base branch
Loading
fromSheraff:fix-table-core-readonly-array-options

Conversation

@Sheraff
Copy link

@SheraffSheraff commentedSep 20, 2025
edited by coderabbitaibot
Loading

When used as the type for a function parameter,readonly ensures that the parameter will not be mutated inside the function.

Thecolumns anddata array inputs are never modified bytable-core. They should thus be marked asreadonly 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:

constComponent=()=>{const{ data}=useQuery({ ...})consttable=useReactTable({ data, ...})

In a case like this,data comes from thetanstack/query cache, and as such must be immutable. IfuseReactTable can guarantee that it won't modify the array we pass in, then we can passdata 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.

@nx-cloud
Copy link

nx-cloudbot commentedSep 20, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commite6b7bbd

CommandStatusDurationResult
nx run-many --targets=build --exclude=examples/**✅ Succeeded29sView ↗

☁️Nx Cloud last updated this comment at2025-09-22 07:18:23 UTC

@coderabbitai
Copy link

coderabbitaibot commentedSep 22, 2025
edited
Loading

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 arrays
docs/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 parameters
packages/table-core/src/utils/getCoreRowModel.ts,packages/table-core/src/core/table.ts
Adjusted helper parameters to acceptreadonly 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 nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe 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 thedocumentation 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 thisDiscord post.


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

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/table-core/src/utils/getCoreRowModel.ts (1)

25-25:Readonly input for accessRows is correct; no functional change.

This tightens the contract without breaking callers. One consistency follow‑up: consider makingCoreOptions['getSubRows'] returnreadonly TData[] to propagate immutability through nested data as well (backward‑compatible sinceTData[] is assignable toreadonly TData[]). See suggested diff in table.ts comment below.

docs/api/core/table.md (1)

22-22:Docs correctly reflect readonly fordata andcolumns.

For completeness with nested rows, consider updatinggetSubRows’ return type to readonly too.

Apply this diff:

-getSubRows?: (-  originalRow: TData,-  index: number-) => undefined | TData[]+getSubRows?: (+  originalRow: TData,+  index: number+) => undefined | readonly TData[]

Also applies to: 34-34

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and betweend538a90 ande6b7bbd.

📒 Files selected for processing (3)
  • docs/api/core/table.md (2 hunks)
  • packages/table-core/src/core/table.ts (3 hunks)
  • packages/table-core/src/utils/getCoreRowModel.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-15T15:05:14.117Z
Learnt from: stevenwjyPR: TanStack/table#6094File: packages/table-core/src/utils/getGroupedRowModel.ts:74-78Timestamp: 2025-09-15T15:05:14.117ZLearning: In TanStack Table's Row interface, the `subRows` property is typed as `Row<TData>[]` (not optional) and the `createRow` function always initializes it as an empty array, so `subRows` is guaranteed to never be undefined.

Applied to files:

  • docs/api/core/table.md
  • packages/table-core/src/utils/getCoreRowModel.ts
📚 Learning: 2025-09-15T15:05:14.117Z
Learnt from: stevenwjyPR: TanStack/table#6094File: packages/table-core/src/utils/getGroupedRowModel.ts:74-78Timestamp: 2025-09-15T15:05:14.117ZLearning: In TanStack Table's Row interface, the `subRows` property is typed as `Row<TData>[]` (not optional) and the `createRow` function always initializes it as an empty array using `subRows ?? []`, so `subRows` is guaranteed to never be undefined.

Applied to files:

  • docs/api/core/table.md
  • packages/table-core/src/utils/getCoreRowModel.ts
🧬 Code graph analysis (1)
packages/table-core/src/core/table.ts (1)
packages/table-core/src/types.ts (1)
  • ColumnDef (328-331)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (1)
packages/table-core/src/core/table.ts (1)

81-81:Make getSubRows return readonly and verify no mutations

  • Great move to readonly for columns/data and internal getters.
  • Change signature to return readonly subrows — apply diff below.
-  getSubRows?: (originalRow: TData, index: number) => undefined | TData[]+  getSubRows?: (originalRow: TData, index: number) => undefined | readonly TData[]
  • Verification: the provided ripgrep run returned "No files were searched", so I could not confirm absence of any mutations to options.data / options.columns / _getColumnDefs — re-run the verification script (or allow a repo run) to ensure no mutating calls or assignments exist.

Also applies to: 87-87, 198-198, 450-450.

@pkg-pr-new
Copy link

More templates

@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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Sheraff@lachlancollins

[8]ページ先頭

©2009-2025 Movatter.jp