From aa6c29ee4d1e17752327818900990dbf47bf36de Mon Sep 17 00:00:00 2001 From: Thomas Oddsund Date: Mon, 31 Aug 2026 14:35:21 +0200 Subject: [PATCH] fix(router-core): fix dangling reference to stripped field `DehydratedMatch['b']` is typed by `RouteMatch['__beforeLoadContext']`, and `RouteMatch['__beforeLoadContext']` is tagged `@internal`. This worked fine until `stripInternal` was enabled in fd341ad(PR #4907), which strips `@internal` members from the published `.d.ts`. This has made this reference dangling since `router-core@1.171.16`. f330532 (PR #6118) later moved the interface to its current file unchanged. When 45c4ad8 (PR #7805) rewrote to `load-client.ts` and started importing from `./ssr/types`, the dangling reference was surfaced for consumers with `skipLibCheck: false` in this error: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. We solve this by giving `b` the declared type of `__beforeLoadContext`, instead of indexing into the stripped member. Verified against a built package: the emitted `dist/esm/ssr/types.d.ts` no longer references the internal member, and a minimal consumer repro type-checks cleanly with this dist swapped in. --- .changeset/dehydrated-match-before-load-context-type.md | 5 +++++ packages/router-core/src/ssr/types.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/dehydrated-match-before-load-context-type.md diff --git a/.changeset/dehydrated-match-before-load-context-type.md b/.changeset/dehydrated-match-before-load-context-type.md new file mode 100644 index 00000000000..f3bd7bc5913 --- /dev/null +++ b/.changeset/dehydrated-match-before-load-context-type.md @@ -0,0 +1,5 @@ +--- +'@tanstack/router-core': patch +--- + +Fix `DehydratedMatch['b']`, which was typed by `RouteMatch['__beforeLoadContext']` — a field tagged `@internal`. This worked fine until `stripInternal` was enabled in fd341ad (PR #4907), which strips `@internal` members from the published `.d.ts` and left this reference dangling since `router-core@1.171.16`. Consumers with `skipLibCheck: false` (the TS default) hit a `tsc` error on `@tanstack/router-core`'s own shipped types. Fixed by giving `b` the declared type of `__beforeLoadContext` instead of indexing into the stripped member. diff --git a/packages/router-core/src/ssr/types.ts b/packages/router-core/src/ssr/types.ts index 27bf1118430..b24c7800aec 100644 --- a/packages/router-core/src/ssr/types.ts +++ b/packages/router-core/src/ssr/types.ts @@ -3,7 +3,7 @@ import type { MakeRouteMatch } from '../Matches' export interface DehydratedMatch { i: MakeRouteMatch['id'] - b?: MakeRouteMatch['__beforeLoadContext'] + b?: Record l?: MakeRouteMatch['loaderData'] e?: MakeRouteMatch['error'] u: MakeRouteMatch['updatedAt']