Repository navigation
refactor(router): hide undocumented internals from the published types - #9035
schiller-manuel wants to merge 8 commits into
Conversation
`LoadTransaction` reads `AnyRouter['_handoff']` and react-router's `settleOwner` takes `AnyRouter['_rendered']`. Both members become internal in the following commits, and these declarations would then reference a member the published declarations no longer have. Tag them `@internal`, together with `PendingSession` and `commitMatches`, which use `LoadTransaction`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ublished types Tag with `@internal` the router, match, route and history members, the option fields and the entry-point exports that the docs do not document. They stay in the internal declarations that workspace packages read, and the emitted JavaScript is unchanged. Export statements of the entry files are split so that the hidden names have their own tagged statement; the set of runtime exports per entry is the same. Declarations whose leading JSDoc the bundler keeps in the output (top-level functions and constants, class methods) use a `// @internal` line comment instead, which the bundler drops. `RawStream`, `hydrate`, `json`, `mergeHeaders`, `defaultSerovalDeserializerPlugins`, `attachRouterServerSsrUtils`, `transformReadableStreamWithRouter` and `transformPipeableStreamWithRouter` stay public for now, because the published declarations of the Start packages re-export them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ernals from the published types Tag the bindings' re-exports of hidden core and history names, their own undocumented exports (`Matches`, `Match`, `Asset`, `useTags`, `RouterContextProvider`, `FileRouteLoader`, and `useLayoutEffect` and `reactUse` in react-router), and undocumented members they add: the `meta`, `links`, `scripts`, `styles` and `headScripts` match fields, `HistoryState.__hashScrollIntoViewOptions`, `FileRoute.silent` and react-router's `RouterStores._linkScopes`. `LazyRoute` stays public: the monorepo examples use it as a type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once the internals are hidden, these exported types are no longer reached from any public export of router-core, history or the bindings, and the docs do not name them. Types that another package's published declarations import (`InferSelected`, `InferShouldThrow`, `InferStrict`, `RouteLoaderEntry`, `CreateFileRoute`, `ResolveValidatorInput`, `ResolveValidatorInputFn`, `UnionToIntersection`, `OnRawStreamCallback`) stay public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ation Remove the `commitLocation` section and its mention in the SSR guide, pass route objects to `loadRouteChunk` in the preloading samples in place of `router.routesByPath`, and remove the `router.routesById` snippets from the debugging guide. Add `fullPath` to the `RouteMatch` type and document `history.back`, `history.forward` and `history.go`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The server-functions e2e routes compare results with a local helper in place of `deepEqual`. - The vitest-app e2e tests read `route.options` through a typed helper, since the project also runs as an installed copy outside the repository. - The hydration benchmarks read `router.state` in place of `router.stores`. - The dev-ssr-styles e2e tests (`DEV_STYLES_ATTR`) and the client-nav link-performance, history, rewrites and hydration benchmarks (`history.location`, `history.length`, `@tanstack/router-core/isServer` and the `isServer` router option) opt into the internal declarations by extending `packages/tsconfig.paths.json`, and their type checks now depend on `compile`. The dev-ssr-styles projects keep their own `paths`, so the opt-in sits in a tsconfig for the tests only. - The `*-full` bundle-size scenarios drop the hidden exports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 924f4e2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
|
View your CI Pipeline Execution ↗ for commit 924f4e2
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview12 package(s) bumped directly, 17 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
The following scenarios have bundle-size changes compared with the baseline:
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
Merging this PR will degrade performance by 6.14%Warning TanStack has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 13, 2026 to keep using CodSpeed. 1 warning, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
🎯 Changes
Stacked on #9034.
A name that
docs/does not document is internal. This tags those names@internalin router-core, history and the three router bindings, so they leave the declarations users install and stay typed for workspace packages (throughdist-ts). Runtime is unchanged: emitted.js/.cjsis byte-identical, apart fromdist/source/index.jsxin solid-router and vue-router, where split export statements show up as written (same names, same modules).The diff of
packages/*/api/*.api.mdis the list of what left the public surface; the changeset lists the names by group.createHistory,parseHrefandnormalizeProtocolRelativein history, and 19 to 22 re-exports per binding. Entry files now keep hidden names in their own taggedexport { … } fromstatement.// @internalis used where the bundler keeps JSDoc on top-level functions, constants and class methods, so the JavaScript stays identical. TypeScript strips both forms.commitLocationand theroutesByPath/routesByIdsamples, addmatch.fullPath, documenthistory.back/forward/go.deepEqualandroute.optionsuses, move the hydration benchmarks torouter.state, opt thedev-ssr-stylestests and five client-nav benchmarks into the internal types with acompiledependency. The*-fullbundle-size scenarios dropAsset,Match,Matches,RouterContextProvideranduseTags, so they measure less (−57 to −94 B gzip); every other scenario is unchanged.Kept public for now:
RawStream, and on/ssr/clientand/ssr/serverhydrate,json,mergeHeaders,defaultSerovalDeserializerPlugins,attachRouterServerSsrUtils,transformReadableStreamWithRouter,transformPipeableStreamWithRouter.router.serverSsr,router.routesById,createSerializationAdapter,isMatch,SearchParamError,PathParamError,serializationAdapters,ssr.nonce,Body/Html(vue),ScrollRestoration.Open questions, kept public until decided:
LazyRoute: tworouter-monorepo-simple-lazyexamples use it as a type.Route.Link,RouteApi.Link,RouteApi.notFound: used in e2e projects, not documented.trailingSlashOptions,defaultSerializeError,DEV_STYLES_ATTRare hidden from the entry but public types still use them throughtypeof.Exported types hidden because nothing public references 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,WithoutEmptyBindings only:
ValidateUseSearchOptions,ValidateUseParamsOptions,InferStructuralSharing(react),VueNode(vue). history:NavigationBlocker.Also hidden beyond the agreed lists (undocumented, unused outside
packages/): the match fields the bindings add (meta,links,scripts,styles,headScripts),HistoryState.__hashScrollIntoViewOptions,FileRoute.silent,RouterStores._linkScopes.Validated locally for
packages/*without the Nx cache:build,compile,test:types,test:unit,test:eslint,test:build(231 tasks), andtscover all 419 example, e2e and benchmark tsconfigs with no new failures. Not run: the Playwright e2e suites. Draft because it inherits the redtest:buildof #9032 until TanStack/config#443 is released.Written with AI assistance (Claude Code).
✅ Checklist
🚀 Release Impact
🤖 Generated with Claude Code