Which project does this relate to?
Router
Describe the bug
When passing a Zod v4 schema object directly to validateSearch, TanStack Router fails to infer the search params output type. As a result, Route.useSearch() returns any, and any code that depends on the typed search params also loses type safety.
According to the documentation, there's no need to use any zodValidator object when using zod v4 : https://tanstack.com/router/latest/docs/guide/search-params#zod
The app runs well (with a Vite dev server) but the TS error is present.
Complete minimal reproducer
https://github.com/lethib/validation_issue
Steps to Reproduce the Bug
- Clone the minimal reproducer repo
- Install bun
bun install inside the repo
bun run typecheck at the root of the repo
Steps are also written in the minimal reproducer repo README.
Expected behavior
Normally, we getting the params from the Route.useSearch(), their type should be infer as the validator type.
Screenshots or Videos
No response
Platform
- Router / Start Version: [e.g. 1.170.4]
- OS: [e.g. macOS]
- Browser: [e.g. Chrome]
- Bundler: [e.g. vite]
- Bundler Version: [e.g. 8.0.13]
Additional context
Claude's investigation if it helps 👇🏽
Root cause: Zod v4 declares its Standard Schema property as "~standard": ZodStandardSchemaWithJSON<this> using a polymorphic this type. When TanStack Router's ResolveValidatorOutput conditional type evaluates TValidator['~standard']['types']['output'], TypeScript cannot resolve this through an indexed access type in a generic context, so the output type collapses to any.
Which project does this relate to?
Router
Describe the bug
When passing a Zod v4 schema object directly to
validateSearch, TanStack Router fails to infer the search params output type. As a result,Route.useSearch()returnsany, and any code that depends on the typed search params also loses type safety.According to the documentation, there's no need to use any
zodValidatorobject when usingzodv4 : https://tanstack.com/router/latest/docs/guide/search-params#zodThe app runs well (with a Vite dev server) but the TS error is present.
Complete minimal reproducer
https://github.com/lethib/validation_issue
Steps to Reproduce the Bug
bun installinside the repobun run typecheckat the root of the repoSteps are also written in the minimal reproducer repo README.
Expected behavior
Normally, we getting the params from the
Route.useSearch(), their type should be infer as the validator type.Screenshots or Videos
No response
Platform
Additional context
Claude's investigation if it helps 👇🏽
Root cause: Zod v4 declares its Standard Schema property as
"~standard": ZodStandardSchemaWithJSON<this>using a polymorphicthistype. When TanStack Router'sResolveValidatorOutputconditional type evaluatesTValidator['~standard']['types']['output'], TypeScript cannot resolvethisthrough an indexed access type in a generic context, so the output type collapses toany.