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
conscious-sapphireOP•4w ago
For the second version I get:
Thanks
ugly-tan•4w 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.
ugly-tan•4w 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...
conscious-sapphireOP•4w 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.
thanksugly-tan•4w ago
then please provide a complete minimal example
equal-aqua•4w ago
You need to add
SearchSchemaInput
and mark the redirect
property as optional:
conscious-sapphireOP•4w ago
Thanks @shelly! @Manuel Schiller The only thing I had to change in my 2nd example was making the
redirect
-prop optional.