Uh oh!
There was an error while loading. Please reload this page.
refactor(router-core): strip internal types from public build - #4907
Merged
Conversation
Contributor
View your CI Pipeline Execution ↗ for commit 52a8552
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter@tanstack/directive-functions-plugin@tanstack/eslint-plugin-router@tanstack/history@tanstack/react-router@tanstack/react-router-devtools@tanstack/react-router-ssr-query@tanstack/react-start@tanstack/react-start-client@tanstack/react-start-plugin@tanstack/react-start-server@tanstack/router-cli@tanstack/router-core@tanstack/router-devtools@tanstack/router-devtools-core@tanstack/router-generator@tanstack/router-plugin@tanstack/router-ssr-query-core@tanstack/router-utils@tanstack/router-vite-plugin@tanstack/server-functions-plugin@tanstack/solid-router@tanstack/solid-router-devtools@tanstack/solid-start@tanstack/solid-start-client@tanstack/solid-start-plugin@tanstack/solid-start-server@tanstack/start-client-core@tanstack/start-plugin-core@tanstack/start-server-core@tanstack/start-server-functions-client@tanstack/start-server-functions-fetcher@tanstack/start-server-functions-server@tanstack/start-storage-context@tanstack/valibot-adapter@tanstack/virtual-file-routes@tanstack/zod-adaptercommit: |
Uh oh!
There was an error while loading. Please reload this page.
Sheraff pushed a commit
that referenced
this pull request
Sep 15, 2025
… .d.ts files (#5134) Fixes#5116 ### Root Cause In PR #4907, the TypeScript compiler option `stripInternal` was enabled in tsconfig.json, which causes TypeScript to remove any declarations marked with `@internal` from the published `.d.ts` files. This resulted in TypeScript compilation errors for library users who have set the TypeScript compiler option `skipLibCheck` to `false`, because the following members were missing: - `InferStructuralSharing` type in `react-router` - `handleHashScroll` function in `router-core > scrollRestoration` ### Fix - This PR replaces the `@internal` annotation with the `@private` annotation. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated internal API annotations in routing packages to mark certain items as private, improving the accuracy of generated developer documentation. * No changes to public APIs, behavior, or performance. * No user-facing impact. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
…dratedMatch `DehydratedMatch['b']` is typed as `MakeRouteMatch['__beforeLoadContext']`, an indexed-access into `RouteMatch['__beforeLoadContext']`. That field has been tagged `@internal` since TanStack#4600 (2025-07-11); TanStack#4907 (2025-08-10) then enabled `stripInternal` repo-wide specifically to remove `@internal` members from the published `.d.ts`. From `router-core@1.171.16` onward the published types no longer have `RouteMatch.__beforeLoadContext`, but `ssr/types.ts` (moved to its current path by TanStack#6118, content otherwise unchanged) still indexes into it, leaving a dangling reference. This went unnoticed by plain SPA consumers for weeks because nothing in the always-imported client path pulled `ssr/types.ts` into their type graph. TanStack#7805's `load-client.ts` rewrite (2026-08-04) changed that: it imports `TsrSsrGlobal` from `./ssr/types`, and `load-client.ts` is core hydration code every consumer's `tsc` walks, SSR or not. Combined with `skipLibCheck: false` (the TS default), that's enough to fail with: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. Since `__beforeLoadContext` is declared as `Record<string, unknown>` in source, give `b` that concrete type directly 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 (`skipLibCheck: false`, importing `createRouter`/`createRootRoute`) type- checks cleanly with this dist swapped in.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`DehydratedMatch['b']` indexes into `RouteMatch['__beforeLoadContext']`, which is tagged `@internal`. `stripInternal` (enabled in TanStack#4907) strips `@internal` members from the published `.d.ts`, so this reference has been dangling since `router-core@1.171.16`. TanStack#6118 later moved the interface to its current file unchanged. TanStack#7805's `load-client.ts` rewrite started importing from `./ssr/types`, surfacing the dangling reference for any consumer with `skipLibCheck: false`: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. Give `b` `__beforeLoadContext`'s declared source type directly 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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`DehydratedMatch['b']` indexes into `RouteMatch['__beforeLoadContext']`, which is tagged `@internal`. `stripInternal` (enabled in fd341ad (PR TanStack#4907)) strips `@internal` members from the published `.d.ts`, so this reference has been dangling since `router-core@1.171.16`. f330532 (PR TanStack#6118) later moved the interface to its current file unchanged. 45c4ad8 (PR TanStack#7805)'s `load-client.ts` rewrite started importing from `./ssr/types`, surfacing the dangling reference for any consumer with `skipLibCheck: false`: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. Give `b` `__beforeLoadContext`'s declared source type directly 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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`DehydratedMatch['b']` indexes into `RouteMatch['__beforeLoadContext']`, which is tagged `@internal`. `stripInternal` (enabled in fd341ad (PR TanStack#4907)) strips `@internal` members from the published `.d.ts`, so this reference has been dangling since `router-core@1.171.16`. f330532 (PR TanStack#6118) later moved the interface to its current file unchanged. 45c4ad8 (PR TanStack#7805)'s `load-client.ts` rewrite started importing from `./ssr/types`, surfacing the dangling reference for any consumer with `skipLibCheck: false`: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. Type `b` directly as `Record<string, unknown>` — the type `__beforeLoadContext` has in source — 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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`DehydratedMatch['b']` indexes into `RouteMatch['__beforeLoadContext']`, which is tagged `@internal`. `stripInternal` (enabled in fd341ad (PR TanStack#4907)) strips `@internal` members from the published `.d.ts`, so this reference has been dangling since `router-core@1.171.16`. f330532 (PR TanStack#6118) later moved the interface to its current file unchanged. 45c4ad8 (PR TanStack#7805)'s `load-client.ts` rewrite started importing from `./ssr/types`, surfacing the dangling reference for any consumer with `skipLibCheck: false`: error TS2339: Property '__beforeLoadContext' does not exist on type 'MakeRouteMatch'. Give `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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`DehydratedMatch['b']` is typed by `RouteMatch['__beforeLoadContext']`. The problem is that `RouteMatch['__beforeLoadContext']` is tagged `@internal`. `stripInternal` (enabled in fd341ad(PR TanStack#4907)) strips `@internal` members from the published `.d.ts`, so this reference has been dangling since `router-core@1.171.16`. f330532 (PR TanStack#6118) later moved the interface to its current file unchanged. 45c4ad8 (PR TanStack#7805)'s `load-client.ts` rewrite started importing from `./ssr/types`, surfacing the dangling reference for any consumer with `skipLibCheck: false`: 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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`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.
oddsund added a commit
to oddsund/router
that referenced
this pull request
Aug 31, 2026
`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.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes we use the
@internalJSDoc tag, and--stripInternaltypescript compiler option to remove internal keys from the public.d.tsfiles.Docs for
stripInternal: https://www.typescriptlang.org/tsconfig/#stripInternalThis helps ensuring internal values aren't considered as part of the public API surface by users, allowing us more flexibility in refactoring.
Warning
This PR proposes we add
stripInternalto the entire repo, not justrouter-core. However there are already some values marked as internal that weren't added by this PR:InferStructuralSharinginreact-routerhandleHashScrollinrouter-core > scrollRestorationInferFootypes inrouter-core > typePrimitivesas a result of this, we might have to switch some of those
@internaltags to something else (like@privatemaybe?) because they are, in fact, necessary for the build to be correct.Example:
gets compiled as
.d.tsto