You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(Table): accept readonly arrays in data prop - #7412
📖 Documentation (updates to the documentation or readme)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality)
✨ New feature (a non-breaking change that adds functionality)
🧹 Chore (updates to the build process or auxiliary tools and libraries)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
The data prop was typed as T[], so a readonly array (from readonly(), a computed<readonly T[]> or a query cache) failed to type check, even though the table never mutates it. Callers had to cast or pass [...data].
The prop is now readonly T[]. TanStack still wants a mutable TData[], so the internal ref starts from a copy, the same thing the props.data watcher already does on every update. Mutable arrays keep working as before.
No actionable comments were generated in the recent review.
Walkthrough
The table’s data prop now accepts readonly arrays. The component copies supplied data into its internal ref during initialisation. A test mounts the table with readonly data and checks that the rendered body-row count matches the data length.
The UTabledata prop now accepts readonly arrays, and the table copies the rows internally, so the caller's array is not modified. Existing mutable-array usage keeps working. No actionable merge risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the Table component's data prop now accepts readonly arrays. It follows the conventional commit format and fits the linked issue #7411 and the changeset.
Description check
The description explains the change. It states that the data prop changed from T[] to readonly T[], that the internal ref now starts from a copy because TanStack requires a mutable array, and that it …
Linked Issues check
Issue #7411 requires the UTabledata prop to accept readonly arrays and requires the internal state to start from a copy, because TanStack Table types data as mutable. At the reviewed head, `src…
Out of Scope Changes check
The PR changes two files only. src/runtime/components/Table.vue changes the data prop type and the initial ref creation, which are the two changes the issue requests. `test/components/Table.spec.t…
Full details: Description check
Explanation
The description explains the change. It states that the data prop changed from T[] to readonly T[], that the internal ref now starts from a copy because TanStack requires a mutable array, and that it links issue #7411. It is related to the changeset.
Full details: Linked Issues check
Explanation
Issue #7411 requires the UTabledata prop to accept readonly arrays and requires the internal state to start from a copy, because TanStack Table types data as mutable. At the reviewed head, src/runtime/components/Table.vue declares data?: readonly T[] (was T[]). The initial internal ref is created from props.data ? [...props.data] : [], which matches the proposed change in the issue. The existing props.data watcher already copies on update, so the readonly-to-mutable boundary holds for initialisation and updates. Mutable arrays still work, because a copy of a mutable array is also a valid input. test/components/Table.spec.ts adds an automated test, 'accepts readonly data', which mounts Table with readonly(data) and checks the rendered tbody tr count against data.length. The issue has no non-coding requirements. The PR description and the issue agree. Evidence was taken from the whole-PR diff against the merge base. I did not run the test suite. The diff does not show a regression path for the watcher or the createRef deep option.
Full details: Out of Scope Changes check
Explanation
The PR changes two files only. src/runtime/components/Table.vue changes the data prop type and the initial ref creation, which are the two changes the issue requests. test/components/Table.spec.ts adds the readonly import and one test for the new behaviour. Both changes support the linked objective. No unrelated refactoring, documentation, or configuration change appears in the diff. The PR description has an unchecked documentation item, but no documentation change is required by the issue's coding scope.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 3879d26 and 0222a56.
Files selected for processing: 2
src/runtime/components/Table.vue
test/components/Table.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Resolves #7411
❓ Type of change
📚 Description
The
dataprop was typed asT[], so a readonly array (fromreadonly(), acomputed<readonly T[]>or a query cache) failed to type check, even though the table never mutates it. Callers had to cast or pass[...data].The prop is now
readonly T[]. TanStack still wants a mutableTData[], so the internal ref starts from a copy, the same thing theprops.datawatcher already does on every update. Mutable arrays keep working as before.📝 Checklist