Skip to content
7 changes: 7 additions & 0 deletions .changeset/cool-months-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/router-core': patch
---

Fix consumer typechecking with `skipLibCheck: false` by omitting the internal beforeLoad context field from published dehydrated match declarations.

Retain the exported `isAbsoluteUrl` declaration used by framework bindings so the package entry point does not reference a stripped symbol.
22 changes: 11 additions & 11 deletions packages/react-router/tests/issue-8128-context.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
createRouter,
} from '../src'
import { hydrate } from '../src/ssr/client'
import type { DehydratedMatch } from '@tanstack/router-core/ssr/client'

test('#8128: leaving a hydrated root not-found page preserves beforeLoad context', async () => {
const rootRenders: Array<string | undefined> = []
Expand Down Expand Up @@ -58,21 +59,20 @@ test('#8128: leaving a hydrated root not-found page preserves beforeLoad context
defaultPendingMinMs: 0,
})
const rootMatch = router.matchRoutes(router.latestLocation)[0]!
// Model the public server bootstrap for a hydrated root-level not-found.
// Model the server bootstrap for a hydrated root-level not-found.
const dehydratedMatch: DehydratedMatch & { b: Record<string, unknown> } = {
i: dehydrateSsrMatchId(rootMatch.id),
b: { locale: 'en' },
u: Date.now(),
s: 'success',
ssr: true,
g: true,
}
window.$_TSR = {
router: {
manifest: { routes: {} },
dehydratedData: {},
matches: [
{
i: dehydrateSsrMatchId(rootMatch.id),
b: { locale: 'en' },
u: Date.now(),
s: 'success',
ssr: true,
g: true,
},
],
matches: [dehydratedMatch],
},
h: vi.fn(),
e: vi.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/router-core/src/ssr/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { MakeRouteMatch } from '../Matches'

export interface DehydratedMatch {
i: MakeRouteMatch['id']
/** @internal */
b?: MakeRouteMatch['__beforeLoadContext']
l?: MakeRouteMatch['loaderData']
e?: MakeRouteMatch['error']
Expand Down
1 change: 0 additions & 1 deletion packages/router-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { isServer } from '@tanstack/router-core/isServer'
import type { RouteIds } from './routeInfo'
import type { AnyRouter } from './router'

/** @internal */
export function isAbsoluteUrl(url: string | undefined): boolean {
// Both URL APIs stringify undefined and reject it without a base URL.
if (URL.canParse) {
Expand Down
Loading