fix(router-core): fix search middleware type to use schema output#7381
fix(router-core): fix search middleware type to use schema output#7381sprusr wants to merge 1 commit into
Conversation
Bundle Size Benchmarks
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe type of search middlewares in ChangesSearch Middleware Type Update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
Long time TanStack Router fan, first time contributor. I spent a bit of time validating my theory with this one, so hopefully haven't jumped to the wrong conclusion. As an aside, I would love to see more comprehensive support of asymmetrical schemas particularly when it comes to search params. An example use case: I'm unhappy with the appearance of how arrays of strings are encoded in the url by default, and would prefer to have them as space-separated values - being able to do this with Zod codecs would be wonderful (I am already, but it relies on own middleware). |
|
In fact if maintainers agree with conclusions here then I think |
Summary
The type for
searchpassed to a route's search middleware is currently set to the input of whatever is passed tovalidateSearch. In reality this value is the output of the search validator.In the majority of cases these types are the same, but it becomes a pronounced issue with asymmetric schemas, for example with Zod codecs:
The value that we get in the search middleware is a
BigIntbut it's typed as anumber.Changes
Simple switch from
ResolveFullSearchSchemaInputtoResolveFullSearchSchema.Reproduction
You can find here a small TanStack Start project with a demo of the mismatch: https://github.com/sprusr/tanstack-router-search-middleware-types
Summary by CodeRabbit