Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .changeset/hide-router-internals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@tanstack/router-core': patch
'@tanstack/history': patch
'@tanstack/react-router': patch
'@tanstack/solid-router': patch
'@tanstack/vue-router': patch
---

Remove undocumented internals from the published type declarations. Runtime behaviour is unchanged: every value is still exported from the same entry points and every property still exists at runtime. Only the types no longer name them. Code that used one of these names gets a type error and needs a cast. They are internal and can change in any release.

Router (`RouterCore` and the framework `Router` classes): `_tx`, `_cache`, `_serverResult`, `_rendered`, `_scroll`, `_refreshRoute`, `_replaceRouteChunk`, `_lifecycleEnd`, `_flights`, `_preloads`, `_preflight`, `_handoff`, `_pending`, `_committed`, `_pendingLocation`, `_commitPromise`, `stores`, `batch`, `emit`, `subscribers`, `isServer`, `ssr`, `origin`, `basepath`, `rewrite`, `protocolAllowlist`, `startTransition`, `startViewTransition`, `shouldViewTransition`, `tempLocationKey`, `getStoreConfig`, `latestLocation`, `processedTree`, `resolvePathCache`, `lightweightCache`, `staticLocations`, `pathParamsDecoder`, `updateLatestLocation`, `buildRouteTree`, `setRoutes`, `parseLocation`, `matchRoutesInternal`, `getMatchedRoutes`, `matchRoutesLightweight`, `buildAndCommitLocation`, `resolveRedirect`, `serverSsrLifecycle`, `commitLocation` and `routesByPath`.

Matches (`RouteMatch`): `index`, `loaderDeps`, `preload`, `invalid`, `headers`, `_strictParams`, `_strictSearch` and `_notFound`, and the `meta`, `links`, `scripts`, `styles` and `headScripts` fields that the framework packages add.

Routes (`Route` and `BaseRoute`): `options`, `children`, `rank`, `init`, `isRoot`, `originalIndex` and `updateLoader`. `FileRoute`: `silent`.

History (`RouterHistory`): `location`, `length`, `subscribe`, `subscribers`, `canGoBack`, `block`, `notify`, `flush`, `createHref`, `_getBlockers`, `_ignoreSubscribers` and `_ignoreNextBeforeUnload`. `history.go` and `history.forward` stay and are now documented. `HistoryState.__hashScrollIntoViewOptions` in the framework packages is hidden as well.

Options: `_fromLocation`, `_isNavigate`, `_includeValidateSearch`, `_signal`, `_skipLocationUpdate`, `unsafeRelative`, the deprecated `startTransition` navigation option, and the router options `additionalContext`, `isServer`, `isShell` and `isPrerendering`.

Exports of `@tanstack/router-core`: `TSR_DEFERRED_PROMISE`, `invariant`, `preloadWarning`, `DEV_STYLES_ATTR`, `appendUniqueUserTags`, `createInlineCssStyleAsset`, `getAssetCrossOrigin`, `getManifestScriptFormat`, `getScriptPreloadAttrs`, `getStylesheetHref`, `resolveManifestAssetLink`, `resolveManifestCssLink`, `_getAssetMatches`, `_getRenderedMatches`, `_isRouteDeparting`, `composeSsrBodyScripts`, `getSsrBodyScriptParts`, `joinPaths`, `cleanPath`, `trimPathLeft`, `trimPathRight`, `trimPath`, `removeTrailingSlash`, `exactPathTest`, `resolvePath`, `interpolatePath`, `getRouteSegments`, `hasMissingPathParams`, `encode`, `decode`, `createNonReactiveMutableStore`, `createNonReactiveReadonlyStore`, `defaultSerializeError`, `getLocationChangeInfo`, `getInitialRouterState`, `trailingSlashOptions`, `createRouterConfig`, `functionalUpdate`, `hasKeys`, `replaceEqualDeep`, `deepEqual`, `createControlledPromise`, `isPromise`, `isModuleNotFoundError`, `escapeHtml`, `getUrlScheme`, `isDangerousProtocol`, `buildDevStylesUrl`, `isResolvedRedirect`, `parseRedirect`, `defaultGetScrollRestorationKey`, `getElementScrollRestorationEntry`, `storageKey`, `setupScrollRestoration`, `makeSerovalPlugin` and `executeRewriteInput`.

Exports of `@tanstack/router-core/ssr/server`: `waitForRequest`, `bindSsrResponseToRequest`, `createSsrStreamResponse`, `disposeSsrResponse`, `getSsrStatus`, `isSsrResponse`, `normalizeSsrResponse`, `replaceSsrResponse`, `stripSsrResponseBody`, `transformHtmlStringWithRouter`, `renderSsrHtmlResponse`, `getNormalizedURL`, `getOrigin`, `defaultSerovalDeserializerPlugins`, `createRawStreamRPCPlugin` and `makeSsrSerovalPlugin`. Of `@tanstack/router-core/ssr/client`: `createDefaultSerovalPlugins`, `defaultSerovalPlugins`, `makeSerovalPlugin` and `createRawStreamDeserializePlugin`. Of `@tanstack/router-core/isServer`: `isServer` and `loadServerRoute`. Of `@tanstack/router-core/scroll-restoration-script`: `getScrollRestorationScriptForRouter`.

Exports of `@tanstack/history`: `createHistory`, `parseHref`, `normalizeProtocolRelative` and the `NavigationBlocker` type.

Exports of the framework packages: `joinPaths`, `cleanPath`, `trimPath`, `trimPathLeft`, `trimPathRight`, `resolvePath`, `interpolatePath`, `functionalUpdate`, `replaceEqualDeep`, `deepEqual`, `createControlledPromise`, `createHistory`, `createRouterConfig`, `Matches`, `Match`, `Asset`, `useTags`, `RouterContextProvider` and `FileRouteLoader`, and in `@tanstack/react-router` also `useLayoutEffect` and `reactUse`.

Types that no public declaration uses any more, from `@tanstack/router-core` and the framework packages that re-export them: `AnyRouteWithContext`, `AnyRouterWithContext`, `AnySearchValidator`, `AnyStandardSchemaValidateInput`, `AnyValidatorFn`, `CommitLocationFn`, `CommitLocationOptions`, `ControllablePromise`, `ControlledPromise`, `CreateLazyFileRoute`, `DefaultSearchValidator`, `EmitFn`, `ErrorRouteProps`, `GetMatchRoutesFn`, `IsAny`, `IsUnion`, `LoadRouteChunkFn`, `MatchLocation`, `MergeAll`, `MergeAllObjects`, `MetaDescriptor`, `ParseLocationFn`, `PickRequired`, `PreloadableObj`, `ResolvedRedirect`, `ResolveSearchSchema`, `ResolveSearchSchemaFn`, `ResolveSearchSchemaFnInput`, `ResolveSearchSchemaInput`, `RouteContextFn`, `RouteLinkEntry`, `RoutePathOptionsIntersection`, `RouterConfig`, `RouterConfigOptions`, `RouterConfigTypes`, `AnyRouterConfig`, `RouterListener`, `RouterManagedInlineCssTag`, `RouterStores`, `SearchValidator`, `StartTransitionFn`, `StringLiteral`, `Timeout`, `ValidateId`, `ValidateNavigateOptionsArray`, `ValidateParams`, `ValidateRedirectOptionsArray`, `ValidateSearch`, `ValidateToPath`, `ValidateUseParamsResult`, `ValidateUseSearchResult` and `WithoutEmpty`; in the framework packages also `ValidateUseSearchOptions` and `ValidateUseParamsOptions`, `InferStructuralSharing` in `@tanstack/react-router` and `VueNode` in `@tanstack/vue-router`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Asset,
Await,
Block,
CatchBoundary,
Expand All @@ -9,12 +8,9 @@ import {
ErrorComponent,
HeadContent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScriptOnce,
Scripts,
ScrollRestoration,
Expand All @@ -41,7 +37,6 @@ import {
useRouter,
useRouterState,
useSearch,
useTags,
} from '@tanstack/react-router'

export const Route = createRootRoute({
Expand All @@ -68,7 +63,6 @@ function RootComponent() {
const canGoBack = useCanGoBack()
const navigate = useNavigate()
const scrollEntry = useElementScrollRestoration({ id: 'root-scroll' })
const tags = useTags()

useBlocker({
shouldBlockFn: () => false,
Expand Down Expand Up @@ -101,24 +95,19 @@ function RootComponent() {
useLocation,
useCanGoBack,
useElementScrollRestoration,
useTags,
Await,
CatchBoundary,
CatchNotFound,
ClientOnly,
DefaultGlobalNotFound,
ErrorComponent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScrollRestoration,
Block,
ScriptOnce,
Asset,
HeadContent,
Scripts,
]
Expand All @@ -143,17 +132,12 @@ function RootComponent() {
void canGoBack
void navigate
void scrollEntry
void tags
void routeMatchResult

return (
<>
<HeadContent />
<ScriptOnce>{'window.__tsr_bundle_size = true'}</ScriptOnce>
<Asset
tag="meta"
attrs={{ name: 'bundle-size', content: 'react-router-full' }}
/>
<Link {...(linkProps as any)}>home</Link>
<SvgLink to="/" aria-label="svg-home">
<circle cx="8" cy="8" r="7" />
Expand All @@ -171,9 +155,6 @@ function RootComponent() {
<CatchNotFound fallback={() => <DefaultGlobalNotFound />}>
<span data-test="catch-not-found" />
</CatchNotFound>
<RouterContextProvider router={router}>
<span data-test="nested-router-context" />
</RouterContextProvider>
<ScrollRestoration />
<Outlet />
<Scripts />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Asset,
Await,
Block,
CatchBoundary,
Expand All @@ -9,12 +8,9 @@ import {
ErrorComponent,
HeadContent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScriptOnce,
Scripts,
ScrollRestoration,
Expand All @@ -41,7 +37,6 @@ import {
useRouter,
useRouterState,
useSearch,
useTags,
} from '@tanstack/react-router'
import {
createMiddleware,
Expand Down Expand Up @@ -91,7 +86,6 @@ function RootComponent() {
const canGoBack = useCanGoBack()
const navigate = useNavigate()
const scrollEntry = useElementScrollRestoration({ id: 'root-scroll' })
const tags = useTags()
const invokeServerFn = useServerFn(helloServerFn)

useBlocker({
Expand Down Expand Up @@ -126,24 +120,19 @@ function RootComponent() {
useLocation,
useCanGoBack,
useElementScrollRestoration,
useTags,
Await,
CatchBoundary,
CatchNotFound,
ClientOnly,
DefaultGlobalNotFound,
ErrorComponent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScrollRestoration,
Block,
ScriptOnce,
Asset,
HeadContent,
Scripts,
]
Expand All @@ -169,7 +158,6 @@ function RootComponent() {
void canGoBack
void navigate
void scrollEntry
void tags
void routeMatchResult
void invokeServerFn

Expand All @@ -180,10 +168,6 @@ function RootComponent() {
</head>
<body>
<ScriptOnce>{'window.__tsr_bundle_size = true'}</ScriptOnce>
<Asset
tag="meta"
attrs={{ name: 'bundle-size', content: 'react-start-full' }}
/>
<Link {...(linkProps as any)}>home</Link>
<SvgLink to="/" aria-label="svg-home">
<circle cx="8" cy="8" r="7" />
Expand All @@ -201,9 +185,6 @@ function RootComponent() {
<CatchNotFound fallback={() => <DefaultGlobalNotFound />}>
<span data-test="catch-not-found" />
</CatchNotFound>
<RouterContextProvider router={router}>
<span data-test="nested-router-context" />
</RouterContextProvider>
<ScrollRestoration />
<Outlet />
<Scripts />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Asset,
Await,
Block,
CatchBoundary,
Expand All @@ -9,12 +8,9 @@ import {
ErrorComponent,
HeadContent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScriptOnce,
Scripts,
ScrollRestoration,
Expand All @@ -41,7 +37,6 @@ import {
useRouter,
useRouterState,
useSearch,
useTags,
} from '@tanstack/solid-router'

export const Route = createRootRoute({
Expand All @@ -68,7 +63,6 @@ function RootComponent() {
const canGoBack = useCanGoBack()
const navigate = useNavigate()
const scrollEntry = useElementScrollRestoration({ id: 'root-scroll' })
const tags = useTags()

useBlocker({
shouldBlockFn: () => false,
Expand Down Expand Up @@ -101,24 +95,19 @@ function RootComponent() {
useLocation,
useCanGoBack,
useElementScrollRestoration,
useTags,
Await,
CatchBoundary,
CatchNotFound,
ClientOnly,
DefaultGlobalNotFound,
ErrorComponent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScrollRestoration,
Block,
ScriptOnce,
Asset,
HeadContent,
Scripts,
]
Expand All @@ -143,17 +132,12 @@ function RootComponent() {
void canGoBack()
void navigate
void scrollEntry
void tags()
void routeMatchResult()

return (
<>
<HeadContent />
<ScriptOnce>{'window.__tsr_bundle_size = true'}</ScriptOnce>
<Asset
tag="meta"
attrs={{ name: 'bundle-size', content: 'solid-router-full' }}
/>
<Link {...(linkProps as any)}>home</Link>
<SvgLink to="/" aria-label="svg-home">
<circle cx="8" cy="8" r="7" />
Expand All @@ -171,9 +155,6 @@ function RootComponent() {
<CatchNotFound fallback={() => <DefaultGlobalNotFound />}>
<span data-test="catch-not-found" />
</CatchNotFound>
<RouterContextProvider router={router}>
{() => <span data-test="nested-router-context" />}
</RouterContextProvider>
<ScrollRestoration />
<Outlet />
<Scripts />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Asset,
Await,
Block,
CatchBoundary,
Expand All @@ -9,12 +8,9 @@ import {
ErrorComponent,
HeadContent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScriptOnce,
Scripts,
ScrollRestoration,
Expand All @@ -41,7 +37,6 @@ import {
useRouter,
useRouterState,
useSearch,
useTags,
} from '@tanstack/solid-router'
import {
createMiddleware,
Expand Down Expand Up @@ -100,7 +95,6 @@ function RootComponent() {
const canGoBack = useCanGoBack()
const navigate = useNavigate()
const scrollEntry = useElementScrollRestoration({ id: 'root-scroll' })
const tags = useTags()
const invokeServerFn = useServerFn(helloServerFn)

useBlocker({
Expand Down Expand Up @@ -135,24 +129,19 @@ function RootComponent() {
useLocation,
useCanGoBack,
useElementScrollRestoration,
useTags,
Await,
CatchBoundary,
CatchNotFound,
ClientOnly,
DefaultGlobalNotFound,
ErrorComponent,
Link,
Match,
MatchRoute,
Matches,
Navigate,
Outlet,
RouterContextProvider,
ScrollRestoration,
Block,
ScriptOnce,
Asset,
HeadContent,
Scripts,
]
Expand All @@ -178,7 +167,6 @@ function RootComponent() {
void canGoBack()
void navigate
void scrollEntry
void tags()
void routeMatchResult()
void invokeServerFn

Expand All @@ -189,10 +177,6 @@ function RootComponent() {
</head>
<body>
<ScriptOnce>{'window.__tsr_bundle_size = true'}</ScriptOnce>
<Asset
tag="meta"
attrs={{ name: 'bundle-size', content: 'solid-start-full' }}
/>
<Link {...linkProps}>home</Link>
<SvgLink to="/" aria-label="svg-home">
<circle cx="8" cy="8" r="7" />
Expand All @@ -210,9 +194,6 @@ function RootComponent() {
<CatchNotFound fallback={() => <DefaultGlobalNotFound />}>
<span data-test="catch-not-found" />
</CatchNotFound>
<RouterContextProvider router={router}>
{() => <span data-test="nested-router-context" />}
</RouterContextProvider>
<ScrollRestoration />
<Outlet />
<Scripts />
Expand Down
Loading
Loading