fix(router-generator): avoid zod function schema for routeTreeFileFooter#6848
fix(router-generator): avoid zod function schema for routeTreeFileFooter#6848CaliLuke wants to merge 1 commit intoTanStack:mainfrom
Conversation
|
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 (2)
📝 WalkthroughWalkthroughThe pull request introduces schema validation support for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
|
View your CI Pipeline Execution ↗ for commit c96cfdb
☁️ Nx Cloud last updated this comment at |
|
@tannerlinsley anything else I need to do to get this patch upstreamed? |
Summary
Replace the
routeTreeFileFooterfunction schema in@tanstack/router-generatorwith a cross-version callable guard.The current config schema uses
z.function().returns(z.array(z.string())), which is a Zod v3-style function schema API and causes compatibility issues for consumers on Zod v4 in this package context.This change narrows the fix to the actual runtime requirement for
routeTreeFileFooter: it only needs to accept either:string[]string[]At runtime, the generator only distinguishes between those two shapes:
Array.isArray(config.routeTreeFileFooter)config.routeTreeFileFooter()So a typed callable guard is sufficient here and avoids consumer-side patching of installed package files.
Changes
z.function().returns(z.array(z.string()))withz.custom<() => string[]>((value) => typeof value === 'function')routeTreeFileFooterWhy
A downstream consumer currently has to patch the published package after install to keep their app working with Zod v4. This change removes the need for that workaround in the
router-generatorconfig surface.Verification
Ran locally:
pnpm --dir packages/router-generator exec vitest run tests/config.test.tspnpm --dir packages/router-generator test:typespnpm --dir packages/router-generator test:eslintpnpm --dir packages/router-generator test:buildAll passed.
Summary by CodeRabbit
New Features
routeTreeFileFooterconfiguration parameter now accepts both static string arrays and factory functions that dynamically return string arrays, providing greater flexibility in defining route tree footer content at configuration time.Tests
routeTreeFileFooteris provided as either a static array or a factory function, ensuring proper value preservation.