Which project does this relate to?
TanStack Start / React Start server entry types.
Describe the bug
The current Server Entry Point docs say request context should be typed by augmenting @tanstack/react-start:
declare module '@tanstack/react-start' {
interface Register {
server: {
requestContext: MyRequestContext
}
}
}
With that in place, this should typecheck:
import handler, { createServerEntry } from '@tanstack/react-start/server-entry'
export default createServerEntry({
fetch(request, env, ctx) {
return handler.fetch(request, {
context: { deps: createAppDeps(env, ctx) },
})
},
})
In our app, TypeScript reports:
Object literal may only specify known properties, and deps does not exist in type BaseContext.
The reason appears to be that @tanstack/react-start/server-entry types ServerEntry using Register from @tanstack/react-router:
import type { Register } from '@tanstack/react-router'
export type ServerEntry = { fetch: RequestHandler<Register> }
So the documented @tanstack/react-start augmentation is not visible to serverEntry.fetch(...); the context type falls back to BaseContext.
Current workaround
We have to duplicate the same server.requestContext augmentation for both modules:
declare module '@tanstack/react-start' {
interface Register {
server: { requestContext: MyRequestContext }
}
}
declare module '@tanstack/react-router' {
interface Register {
server: { requestContext: MyRequestContext }
}
}
This typechecks, but it seems inconsistent with the public docs and leaks Start-specific server context into the router module augmentation.
Expected behavior
The documented @tanstack/react-start augmentation should be sufficient for handler.fetch(request, { context }) / createServerEntry(...).
Alternatively, the docs should mention that @tanstack/react-router also needs to be augmented for the server-entry fetch type.
Versions
@tanstack/react-start: 1.167.59
@tanstack/start-server-core: 1.167.26
@tanstack/start-client-core: 1.168.1
@tanstack/react-router: 1.169.1
TypeScript: 5.9.3
Which project does this relate to?
TanStack Start / React Start server entry types.
Describe the bug
The current Server Entry Point docs say request context should be typed by augmenting
@tanstack/react-start:With that in place, this should typecheck:
In our app, TypeScript reports:
The reason appears to be that
@tanstack/react-start/server-entrytypesServerEntryusingRegisterfrom@tanstack/react-router:So the documented
@tanstack/react-startaugmentation is not visible toserverEntry.fetch(...); the context type falls back toBaseContext.Current workaround
We have to duplicate the same
server.requestContextaugmentation for both modules:This typechecks, but it seems inconsistent with the public docs and leaks Start-specific server context into the router module augmentation.
Expected behavior
The documented
@tanstack/react-startaugmentation should be sufficient forhandler.fetch(request, { context })/createServerEntry(...).Alternatively, the docs should mention that
@tanstack/react-routeralso needs to be augmented for the server-entry fetch type.Versions