Type errors chaining middleware together.
In the docs, it suggests you can chain middleware together while building up state in context. But in this case, the context is not typed unlike the majority of Start because the middleware can be used in different spots.
Maybe we should add an explicit typing for the context that each middleware supports?
Something like createMiddleware().context( z.object( { authUser: AuthUser.optional() } ).passthrough() ).validator(.....).server(...)
So that one can put in compile time guarantees on the context required. I believe it would get rid of the type errors in the middleware functions and also validate you combined multiple middlewares correctly in a server function. Bomb.
FYI: I'm using TanStack/Start+Router v1.120.13.
Maybe we should add an explicit typing for the context that each middleware supports?
Something like createMiddleware().context( z.object( { authUser: AuthUser.optional() } ).passthrough() ).validator(.....).server(...)
So that one can put in compile time guarantees on the context required. I believe it would get rid of the type errors in the middleware functions and also validate you combined multiple middlewares correctly in a server function. Bomb.
FYI: I'm using TanStack/Start+Router v1.120.13.

