Skip to content

fix(router-core): fix dangling reference to stripped field - #8206

Open
oddsund wants to merge 1 commit into
TanStack:mainfrom
oddsund:fix/dehydrated-match-before-load-context-type
Open

fix(router-core): fix dangling reference to stripped field#8206
oddsund wants to merge 1 commit into
TanStack:mainfrom
oddsund:fix/dehydrated-match-before-load-context-type

Conversation

@oddsund

@oddsund oddsund commented Aug 31, 2026

Copy link
Copy Markdown

🎯 Changes

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.

Fixes #8203

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a published TypeScript declaration issue affecting dehydrated route data.
    • Resolved compilation errors for consumers using stricter type-checking settings.
    • Improved compatibility by using a stable, publicly available context type.

`DehydratedMatch['b']` is typed by `RouteMatch['__beforeLoadContext']`,
and `RouteMatch['__beforeLoadContext']` is tagged `@internal`.
This worked fine until `stripInternal` was enabled in fd341ad(PR TanStack#4907),
which strips `@internal` members from the published `.d.ts`. This
has made this reference dangling since `router-core@1.171.16`. f330532
(PR TanStack#6118) later moved the interface to its current file unchanged.
When 45c4ad8 (PR TanStack#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.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 166ba867-bbe6-400f-ba29-821296874e17

📥 Commits

Reviewing files that changed from the base of the PR and between 37877da and aa6c29e.

📒 Files selected for processing (2)
  • .changeset/dehydrated-match-before-load-context-type.md
  • packages/router-core/src/ssr/types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The PR changes DehydratedMatch.b to Record<string, unknown> and adds a patch changeset for @tanstack/router-core. This removes its reference to the internal route match context member.

Changes

Dehydrated match context typing

Layer / File(s) Summary
Update dehydrated match context type
packages/router-core/src/ssr/types.ts, .changeset/dehydrated-match-before-load-context-type.md
DehydratedMatch.b now uses Record<string, unknown> instead of indexing into MakeRouteMatch['__beforeLoadContext']. The changeset declares a patch release for @tanstack/router-core.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to aa6c2

This patch fixes the published SSR type declaration without changing runtime behavior or serialized data. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the router-core fix and the dangling reference caused by a stripped field. It is concise and related to the primary change.
Description check ✅ Passed The description is complete and follows the repository template. It explains the cause, the fix, the reported error, verification results, issue reference, checklist status, and changeset impact.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

router-core: ssr/types.d.ts references stripped @internal field, breaks tsc for consumers typechecking libs

1 participant