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
exotic-emerald•4w ago
can you please provide a full example by forking one of the stackblitz router examples?
adverse-sapphireOP•4w ago
app.tsx
Version: "@tanstack/react-router": "^1.131.36",
exotic-emerald•4w 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.
adverse-sapphireOP•4w ago
For that I need to add almost everything, tanstack query, legend state, etc...
adverse-sapphireOP•4w ago
I think this could be the problem, but no idea how to solve it

adverse-sapphireOP•4w ago
Already update my tsconfig but nothing happens
Didn't solve the issue of the context
exotic-emerald•4w 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
adverse-sapphireOP•4w 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 typedadverse-sapphireOP•4w ago
console.log(context)
- loader function
adverse-sapphireOP•4w ago

exotic-emerald•4w ago
make this a complete example please
adverse-sapphireOP•4w ago
Sorry didn't understand?
adverse-sapphireOP•4w ago
The last print is from my
_auth.tsx

adverse-sapphireOP•4w ago
My
index.tsx

adverse-sapphireOP•4w 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 {}
exotic-emerald•4w ago
this
adverse-sapphireOP•4w ago
ON root route is correctly typed

adverse-sapphireOP•4w ago

adverse-sapphireOP•4w ago
And if I do this:
Works too...
exotic-emerald•4w ago
still waiting for a complete example that reproduces the issue
secure-lavender•3w 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.adverse-sapphireOP•2w ago
Thanks 🙏
adverse-sapphireOP•2w ago
Now facing the issue with search params too

adverse-sapphireOP•2w ago
Property redirect-to does not exist on type {}.
Already try to use zod adapter on validate search but didn't worksecure-lavender•2w ago
Keep debugging, you'll find a solution I'm sure.