Context not typed
Hi everyone.
My context appear as not typed.
This is my code:
router.tsx
__root.tsx
Any idea what I'm doing wrong?
25 Replies
manual-pink•3mo ago
can you please provide a full example by forking one of the stackblitz router examples?
unwilling-turquoiseOP•3mo ago
app.tsx
Version: "@tanstack/react-router": "^1.131.36",manual-pink•3mo ago
please fork that example and modify so it matches your issue: https://tanstack.com/router/latest/docs/framework/react/examples/quickstart-file-based
React TanStack Router Quickstart File Based Example | TanStack Rout...
An example showing how to implement Quickstart File Based in React using TanStack Router.
unwilling-turquoiseOP•3mo ago
For that I need to add almost everything, tanstack query, legend state, etc...
unwilling-turquoiseOP•3mo ago
I think this could be the problem, but no idea how to solve it

unwilling-turquoiseOP•3mo ago
Already update my tsconfig but nothing happens
Didn't solve the issue of the context
manual-pink•3mo ago
rspack bundler has no influence on router types
well without a reproducer we won't be able to find out the issue. try adding one thing at time to find out which one causes it
unwilling-turquoiseOP•3mo ago
Leve it only with
queryClient but same result, when try to access context is typed as {}
The problem is that works, but isn't typedunwilling-turquoiseOP•3mo ago
console.log(context) - loader function
unwilling-turquoiseOP•3mo ago

manual-pink•3mo ago
make this a complete example please
unwilling-turquoiseOP•3mo ago
Sorry didn't understand?
unwilling-turquoiseOP•3mo ago
The last print is from my
_auth.tsx
unwilling-turquoiseOP•3mo ago
My
index.tsx
unwilling-turquoiseOP•3mo ago
My root is very simple
The
app is very simple
is only a outlet
The _auth is where I defined my authentication layout
and then my typescript give me error on the context.user saying that user doesn't exist on {}manual-pink•3mo ago
this
unwilling-turquoiseOP•3mo ago
ON root route is correctly typed

unwilling-turquoiseOP•3mo ago

unwilling-turquoiseOP•3mo ago
And if I do this:
Works too...
manual-pink•3mo ago
still waiting for a complete example that reproduces the issue
exotic-emerald•3mo ago
@TutoDS Try :
instead of
I think tanstack router is looking specifically for
I think tanstack router is looking specifically for
export const Route and doesn't use the module system so export { Router } wouldn't work. Similarly using a variable name other than Route doesn't work either. This caught me out.unwilling-turquoiseOP•3mo ago
Thanks 🙏
unwilling-turquoiseOP•3mo ago
Now facing the issue with search params too

unwilling-turquoiseOP•3mo ago
Property redirect-to does not exist on type {}.
Already try to use zod adapter on validate search but didn't workexotic-emerald•3mo ago
Keep debugging, you'll find a solution I'm sure.