Type Errors when using navigate from useNavigate
Hi, I am getting type errors on my search params when I pass them to the navigate function created by useNavigate. I have put together a very basic example to replicate the issue I am facing:
The above code produces the following type error:
The code works without issue but I don't understand why I am getting the type error from VSCode.
6 Replies
gentle-grayOP•8mo ago
The interesting thing is that works without issue
Here's something even stranger use router.navigate from useRouter does not give the type error.
absent-sapphire•8mo ago
I cannot reproduce this locally
can you please share a complete minimal example (git repo) ?
gentle-grayOP•8mo ago
Funny enough, replicating this for you led me to finding the issue. This is actually a Tanstack Start project using React Query as well and when I was creating the router I had the following code in the
router.tsx: const routerWithQuery = routerWithQueryClient(router as any, queryClient). Removing the as any fixed my issue (and I think some other weird issues I was having). Sorry for the false alarm.absent-sapphire•8mo ago
best outcome!
gentle-grayOP•8mo ago
Turns out if you obliterate the type info of your router you're gonna have a bad time
absent-sapphire•8mo ago