Which project does this relate to?
Start
Describe the bug
The type of the context object which has passed through server middleware is incorrectly inferred as undefined. When I log out the context object, it does actually have the fields I would expect from the middleware, they're just missing from the type.
The context object comes from route middleware in a parent route and is accessed in a child route's server handler. I'm not sure if that's relevant, though. Adding the middleware array directly to the child route's middlleware array also does not correctly set the type on context, it's still typed as undefined. I've added an example in my reproduction to show this.
It seems like the issue is limited to Solid Start. I've recreated the same routes and middleware in React Start and the types are properly inferred. I've included this example in my reproduction for reference.
Your Example Website or App
https://github.com/njGroters/tanstack-context-reproduction
Steps to Reproduce the Bug or Issue
- Clone the repo
- Step into the
solid-broken folder
- Run
npx tsc and see that context is typed as 'undefined'
- Start the local dev server and visit http://localhost:3000/api/public/example. You should see a stringified context object which does have the
supportsGzip field
- Step to the repo's root level and then into the
react-working folder
- Run
npx tsc and see that context is not typed as 'undefined' despite getting created and accessed in the same way
Expected behavior
I would expect the type of context to be inferred from the shape of the data returned under the context field from my middleware chain instead of undefined. This is the result I see in React Start, but not Solid Start.
Screenshots or Videos
No response
Platform
- Start Version: latest (1.167.15)
- OS: macOS
- Browser: Firefox
- Browser Version: 149.0
- Bundler: vite
- Bundler Version: 7.3.1
Additional context
No response
Which project does this relate to?
Start
Describe the bug
The type of the
contextobject which has passed through server middleware is incorrectly inferred asundefined. When I log out thecontextobject, it does actually have the fields I would expect from the middleware, they're just missing from the type.The
contextobject comes from route middleware in a parent route and is accessed in a child route's server handler. I'm not sure if that's relevant, though. Adding the middleware array directly to the child route'smiddllewarearray also does not correctly set the type oncontext, it's still typed asundefined. I've added an example in my reproduction to show this.It seems like the issue is limited to Solid Start. I've recreated the same routes and middleware in React Start and the types are properly inferred. I've included this example in my reproduction for reference.
Your Example Website or App
https://github.com/njGroters/tanstack-context-reproduction
Steps to Reproduce the Bug or Issue
solid-brokenfoldernpx tscand see thatcontextis typed as 'undefined'supportsGzipfieldreact-workingfoldernpx tscand see thatcontextis not typed as 'undefined' despite getting created and accessed in the same wayExpected behavior
I would expect the type of
contextto be inferred from the shape of the data returned under thecontextfield from my middleware chain instead ofundefined. This is the result I see in React Start, but not Solid Start.Screenshots or Videos
No response
Platform
Additional context
No response