Conversation
Route `paramsSchema`/`querySchema` were typed as zod 3's `Z.ZodObject<any>`, which zod 4 schemas do not satisfy, so a consumer moving its schemas to zod 4 (or the `zod/v4` subpath of zod 3.25) lost every route's params/query types. Routing only ever calls `parse` and `merge` on a schema and reads its `_output` marker, and both zod majors expose all three, so the schema type is now the structural `RouteSchema` and the `zod` import is gone from the routing source. The peer range widens to `^3.x || ^4.x`; nothing changes for zod 3 callers. `createRoute.zod4.spec.ts` drives `simpleRoute` with `zod/v4` schemas (typed params/query, and a parent-merged parse rejecting bad params) so the compatibility is tested rather than assumed. The dev `zod` moves to 3.25.76 to make that subpath available in-repo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xa9BAPFheAQLJwta16v67z
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 2, 2026
# [4.12.0](v4.11.1...v4.12.0) (2026-09-02) ### build * typecheck with TypeScript 5.0.2 and skipLibCheck, as master does ([a89f290](a89f290)) ### feat * **routing:** accept zod 4 route schemas ([4a27d80](4a27d80)), closes [#68](#68) * **routing:** accept zod 4 route schemas (4.x) ([b11d273](b11d273))
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 2, 2026
# [5.7.0](v5.6.0...v5.7.0) (2026-09-02) ### chore * **release:** revert the half-published 5.7.0 release commit ([727baa4](727baa4)) * **release:** revert the half-published 5.7.0 release commit ([81b6c78](81b6c78)), closes [#68](#68) [#68](#68) ### feat * **routing:** accept zod 4 route schemas ([9573278](9573278)) * **routing:** accept zod 4 route schemas ([90a2303](90a2303))
|
🎉 This PR is included in version 5.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Why
koordinates is moving its zod schemas to zod 4 (via the
zod/v4subpath of zod 3.25 first, then a real bump). RouteparamsSchema/querySchemaare typed here as zod 3'sZ.ZodObject<any>, which a zod 4 schema does not satisfy, so the moment@kx/routespasses zod 4 schemas every route's params and query degrade to{ [x: string]: any }and ~45 typecheck errors appear across its consumers.What
createRouteno longer importszod. Schemas are typed against a structuralRouteSchema(_output,parse,merge), which is exactly what routing uses and which both zod 3 and zod 4 classic schemas expose.RouteSchemais exported (root,routing,createRoutebarrels) so consumers' emitted declarations can name it.peerDependencies.zodwidens from^3.xto^3.x || ^4.x. Nothing changes for zod 3 callers; existing routing specs are untouched and still pass.createRoute.zod4.spec.tsdrivessimpleRoutewithzod/v4schemas: typed params/query, and a parent-merged parse that rejects bad params. The devzodmoves to 3.25.76 so that subpath exists in-repo.xstate-tree.api.mdregenerated (api-extractor --local).Verification
npm run lint -- --fix: 0 errors.npm test: 135/135 (oneLink › preloadingtiming test flaked once and passed on re-run; unrelated).npm run buildandnpm run api-extractor -- --local: clean.npm run test-examplesfails on master already (App.tsx/TodosMachine.tsxinStateanduseIsRouteActive.specevent.params); this branch adds no new errors there.lib/xstate-tree.d.tsover the installed 5.6.0:@kx/routesonzod/v4typechecks clean and its 209 tests pass, and the downstream route-typing errors clear.Notes
_outputis deprecated in zod 4 in favour ofz.output<>, but it is still declared on every classic schema and is the only version-independent type marker available. If zod 5 drops it,RouteSchemais the single place to update.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xa9BAPFheAQLJwta16v67z