TanStack Start server-entry requestContext type ignores @tanstack/react-start Register augmentation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the @tanstack/react-start/server-entry types and compare their ServerEntry/RequestHandler registration with the Server Entry Point documentation. Reproduce the example using only the documented @tanstack/react-start augmentation, then verify that handler.fetch(request, { context }) and createServerEntry(...) accept the custom request context without duplicating the @tanstack/react-router augmentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100