fix(router-core): properly handle serialization of readonly maps/sets at type level - #7960
Open
pawelblaszczyk5 wants to merge 1 commit into
Open
Conversation
Contributor
📝 WalkthroughWalkthroughThe serializer now supports type-level validation for ChangesReadonly collection serialization
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
pawelblaszczyk5
commented
Aug 5, 2026
| ? ValidateSerializableSet<T, TSerializable> | ||
| : T extends Map<any, any> | ||
| ? ValidateSerializableMap<T, TSerializable> | ||
| : T extends ReadonlyMap<any, any> |
Contributor
Author
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/router-core/tests/serializer.test-d.ts`:
- Around line 49-57: Add a type-level test alongside the existing readonly-map
value case using ReadonlyMap<() => void, string>, and assert that
ValidateSerializable replaces the function key with SerializationError<'Function
may not be serializable'> while preserving the string value type.
🪄 Autofix
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 Plus
Run ID: bcc4f562-ae4e-4767-a350-ccc96c5aed57
📒 Files selected for processing (3)
.changeset/full-flowers-carry.mdpackages/router-core/src/ssr/serializer/transformer.tspackages/router-core/tests/serializer.test-d.ts
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Currently Set and Maps are properly serialized via Seroval. This is reflected on the type level so Set and Maps are properly validated for containing only serializable outputs for server functions. However, this doesn't properly work with ReadonlySet and ReadonlyMap variants:
WIth the patch from this PR applied it works correctly:
Besides validating in my project I've also added tests to existing spec that tested type level serialization behavior to ensure all of these works properly
Summary by CodeRabbit
Bug Fixes
Tests