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.requestContext only 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/native 7.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.ts
apps/logistic/src/shared/logging/server-request-context.types.ts
apps/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.
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
Registerin@tanstack/router-coreis not enough for the generated TanStack Start server entry. The generated server code importsRegisterfrom@tanstack/react-router.Our request-context declaration contains both augmentations:
The
@tanstack/router-coreaugmentation is required for the TypeScript 7 owning-package rule. The@tanstack/react-routeraugmentation 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
Registeraugmentations. The server request-context type then falls back toBaseContext.Steps to Reproduce the Bug
server.requestContextonly in@tanstack/router-core.requestContext.In our monorepo, removing only the
@tanstack/react-routerbridge produces:Restoring both augmentations makes the full workspace type-check pass: 13/13 tasks.
Expected behavior
The
@tanstack/router-coreaugmentation should be sufficient, or TanStack Start should document that the@tanstack/react-routerbridge is required.A future TanStack release should allow removing the bridge without losing
server.requestContexttypes.Screenshots or Videos
Not applicable.
Platform
@tanstack/react-start@1.168.46,@tanstack/react-router@1.170.29,@tanstack/router-core@1.171.24@typescript/native7.0.2Additional 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.tsThe owning-package augmentation targets
@tanstack/router-core. The second augmentation targets@tanstack/react-routerbecause TanStack Start's generated server entry importsRegisterfrom 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.