Type errors with the useSearch hook strict:false
With
useSearch({strict:false}) I receive type errors. Has anyone seeing this as well? I am using the newest version of the router
5 Replies
eastern-cyanOP•2y ago
the validateSearch looks like the following:
Did I miss some configuration to handle the searchParams correctly?
The same type error is visible with
useParams({strict:false}), is that intended?eastern-cyanOP•2y ago
I think that this example currently fails from the docs:
https://tanstack.com/router/v1/docs/guide/type-safety#what-if-i-dont-know-the-route-or-its-a-shared-component-and-i-cant-pass-from
If I use
strict:false then there are no params or search params availableType Safety | TanStack Router Docs
TanStack Router is built to be as type-safe as possible within the limits of the TypeScript compiler and runtime. This means that it's not only written in TypeScript, but that it also fully infers the types it's provided and tenaciously pipes them through the entire routing experience.
Ultimately, this means that you write less types as a deve...
fair-rose•2y ago
I have opened an issue for this. Look what I was recommended to do.
https://github.com/TanStack/router/issues/1007
GitHub
useSearch hook with strict false type error · Issue #1007 · TanStac...
Describe the bug I have a route with some searchParams using validateSearch with zod. When using useSearch with strict=false in an abstract component, TypeScript throws the following error: "P...
genetic-orange•2y ago
please check this thread https://discord.com/channels/719702312431386674/1199424860875669544
eastern-cyanOP•2y ago
Yes, v1.9 is fixing it with
experimental_returnIntersection