Search-Typing issue
Hey 👋🏽 .
I love tanstack router. Does somebody know why following works:
but following not:
The only difference is that in first version I use zod to validate the search, and in the second I do it myself.
7 Replies
fascinating-indigoOP•4mo ago
For the second version I get:
Thanks
generous-apricot•4mo ago
I think you would need to manually specify the input type of the search for the second one. it can be inferred from the zod Schema automatically.
generous-apricot•4mo ago
see SearchSchemaInput https://tanstack.com/router/v1/docs/framework/react/api/router/RouteOptionsType#validatesearch-method
RouteOptions type | TanStack Router React Docs
The RouteOptions type is used to describe the options that can be used when creating a route. RouteOptions properties The RouteOptions type accepts an object with the following properties: getParentRo...
fascinating-indigoOP•4mo ago
You mean this?
I typed it already in my example, didn't I?
If I hover over the redirect-var in the
LoginComponent, I get const redirect: string, so it should be typed correctly. And the error message seems not related to the search-typing.
thanksgenerous-apricot•4mo ago
then please provide a complete minimal example
stormy-gold•4mo ago
You need to add
SearchSchemaInput and mark the redirect property as optional:
fascinating-indigoOP•4mo ago
Thanks @shelly! @Manuel Schiller The only thing I had to change in my 2nd example was making the
redirect-prop optional.