diff --git a/.changeset/cool-months-itch.md b/.changeset/cool-months-itch.md new file mode 100644 index 00000000000..949dd580f1f --- /dev/null +++ b/.changeset/cool-months-itch.md @@ -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. diff --git a/packages/react-router/tests/issue-8128-context.test.tsx b/packages/react-router/tests/issue-8128-context.test.tsx index 80c3c2dd7ec..f615bba8d9d 100644 --- a/packages/react-router/tests/issue-8128-context.test.tsx +++ b/packages/react-router/tests/issue-8128-context.test.tsx @@ -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 = [] @@ -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 } = { + 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(), diff --git a/packages/router-core/src/ssr/types.ts b/packages/router-core/src/ssr/types.ts index 27bf1118430..48b8c8d0e98 100644 --- a/packages/router-core/src/ssr/types.ts +++ b/packages/router-core/src/ssr/types.ts @@ -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'] diff --git a/packages/router-core/src/utils.ts b/packages/router-core/src/utils.ts index f4286d746e7..aefe3042ed0 100644 --- a/packages/router-core/src/utils.ts +++ b/packages/router-core/src/utils.ts @@ -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) {