TypeScript 7 still requires duplicate Register augmentation for Start server-entry context
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
Related to #7353.
With TypeScript 7.0.2 and TanStack Start 1.168.46, augmenting Register in @tanstack/router-core is not enough for the generated TanStack Start server entry. The generated server code imports Register from @tanstack/react-router.
Our request-context declaration contains both augmentations:
import '@tanstack/router-core'
declare module '@tanstack/router-core' {
interface Register {
server: { requestContext: MyRequestContext }
}
}
declare module '@tanstack/react-router' {
interface Register {
server: { requestContext: MyRequestContext }
}
}
The @tanstack/router-core augmentation is required for the TypeScript 7 owning-package rule. The @tanstack/react-router augmentation is still required by TanStack Start server-entry typing.
Complete minimal reproducer
The public reproducer from #7353 is:
https://github.com/alexander-zuev/riposte
Clone it and remove either one of the two Register augmentations. The server request-context type then falls back to BaseContext.
Steps to Reproduce the Bug
- Use a TanStack Start app with the versions listed below.
- Declare
server.requestContextonly in@tanstack/router-core. - Run the app type-check.
- Observe that the generated server entry does not receive
requestContext.
In our monorepo, removing only the @tanstack/react-router bridge produces:
apps/example-base/src/server.test.ts(40,12): error TS18048: 'options.context' is possibly 'undefined'.
apps/example-base/src/server.test.ts(40,29): error TS2339: Property 'requestId' does not exist on type 'BaseContext'.
apps/example-base/src/server.ts(99,78): error TS2353: Object literal may only specify known properties, and 'requestId' does not exist in type 'BaseContext'.
Restoring both augmentations makes the full workspace type-check pass: 13/13 tasks.
Expected behavior
The @tanstack/router-core augmentation should be sufficient, or TanStack Start should document that the @tanstack/react-router bridge is required.
A future TanStack release should allow removing the bridge without losing server.requestContext types.
Screenshots or Videos
Not applicable.
Platform
- Router / Start Version:
@tanstack/react-start@1.168.46,@tanstack/react-router@1.170.29,@tanstack/router-core@1.171.24 - TypeScript:
@typescript/native7.0.2 - OS: Linux
- Bundler: Vite
- Bundler Version: Vite 8.2.1
- Package manager: pnpm 11.20.0
- Framework: TanStack Start
Additional context
The current workaround is intentionally kept in three application request-context declaration files:
apps/example-base/src/shared/logging/server-request-context.types.tsapps/logistic/src/shared/logging/server-request-context.types.tsapps/utm/src/shared/logging/server-request-context.types.ts
The owning-package augmentation targets @tanstack/router-core. The second augmentation targets @tanstack/react-router because TanStack Start's generated server entry imports Register from that re-export.
Please consider updating the generated server-entry type to consume the owning Register, or document this required bridge. This issue is a follow-up with TypeScript 7 context to #7353.
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 with the generated TanStack Start server entry and the reproducer at alexander-zuev/riposte, then inspect the three declaration files listed in the issue. Remove the @tanstack/react-router augmentation and run the workspace type-check to trace why requestContext falls back to BaseContext. Done means the owning @tanstack/router-core augmentation is sufficient, or the required bridge is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100