Skip to content

refactor(start): hide undocumented internals from the published types - #9036

Draft
schiller-manuel wants to merge 9 commits into
refactor/hide-router-internalsfrom
refactor/hide-start-internals
Draft

schiller-manuel wants to merge 9 commits into
refactor/hide-router-internalsfrom
refactor/hide-start-internals

Conversation

@schiller-manuel

Copy link
Copy Markdown
Collaborator

🎯 Changes

Stacked on #9035.

The same rule for the Start packages: a name that docs/ does not document leaves the declarations users install and stays typed for workspace packages through dist-ts. Emitted JavaScript is byte-identical (930 files).

In the implementation packages (start-client-core, start-server-core, start-plugin-core, start-storage-context, the -client / -server packages, react-start-rsc) a name is public only when a framework package re-exports it under a documented name. There are no Vue Start docs, so a name documented for one framework is public in all three.

  • 195 names leave the API reports (43 report files, −1,219 lines). The changeset lists them by entry point.
  • Hidden by ruling: the twelve undocumented request and response helpers on /server (use getRequest()), getRouterInstance, RawStream, json, configureHydrationSuppressions, everything on /client-rpc, /server-rpc and /ssr-rpc, __executeServer, the CSRF internals, the TSS_* constants, and all of start-plugin-core except the two plugin input config types.
  • Hydration strategies get a type-only '~types' brand, so _t, _d, _s, _o, _a and _h can be hidden without HydrationStrategy accepting any object. Strategies from visible(), idle() and so on stay assignable; {} is rejected.
  • router-core hides the names refactor(router): hide undocumented internals from the published types #9035 had to keep for Start: RawStream, hydrate, json, mergeHeaders, defaultSerovalDeserializerPlugins, attachRouterServerSsrUtils and the two stream transforms.
  • Kept because generated or documented user code needs them: Register and StartInstance.getOptions (the route tree footer), the server route option augmentations, and the types docs and user code import (CustomFetch, HydrateOptions, RequestHandler, ServerEntry, TransformAssets, TransformAssetsFn, RequestHeaderName, AnyCompositeComponent).

Outside packages/:

  • 13 example and e2e files move from getRequestHeaders to getRequest(), 3 from getRequestUrl. The two Supabase examples read all cookies with parseCookieHeader from @supabase/ssr in place of getCookies.
  • Ten e2e projects and the three server-fn-transport benchmarks test hidden APIs and opt into the internal types. They define their own ~/* alias, and paths does not merge across extends, so scripts/internal-types-config.mjs now writes the map into opted-in tsconfigs as it does for packages, and the Playwright Nx plugin adds ^compile to their mode builds.

Open questions, kept public until decided:

  • url on server functions (<form action={fn.url}> in 10 e2e files).
  • serverFnMeta in middleware and handler contexts (10 e2e and example files).
  • serializationAdapters on createStart.
  • createFromFetch / createFromReadableStream on /rsbuild/*-decode, an entry only virtual modules use.

Validated locally for packages/* without the Nx cache: build, compile, test:types, test:unit, test:eslint, test:build (231 tasks); tsc over 422 example, e2e and benchmark tsconfigs with the same results before and after; build:vite:ssr and build:rsbuild:ssr for the React, Solid and Vue basic e2e projects. Not run: the Playwright e2e suites. Draft because it inherits the red test:build of #9032 until TanStack/config#443 is released.

Written with AI assistance (Claude Code).

✅ 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).

🤖 Generated with Claude Code

schiller-manuel and others added 8 commits November 30, 2026 04:10
…and hydration strategies and hide their fields

`HydrationStrategy` gets a required, type-only `'~types'` property, and
the runtime fields `_t`, `_d`, `_s`, `_o`, `_a` and `_h` are tagged
`@internal`. Without the brand the published type would have no
required member left and accept any object. The strategy factories
assert the branded type on the objects they return, so the emitted
JavaScript is unchanged.

`InternalHydrateProps` and solid-start-client's `GenericHydrate`, which
only package code uses, are tagged as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hed types

A name is public when the Start docs document it for any framework, or
when a framework package re-exports it under a documented name. The
other exports of the Start packages are tagged `@internal`, with
split export statements where an entry mixes public and hidden names.
They stay in `dist-ts` for the workspace, and the emitted JavaScript is
unchanged.

This covers the undocumented request and response helpers on `/server`,
`RawStream`, `getRouterInstance`, `configureHydrationSuppressions`,
every export of `/client-rpc`, `/server-rpc` and `/ssr-rpc`, the CSRF
and serialization internals, the `TSS_*` constants, all of
start-storage-context and start-plugin-core except the two plugin input
config types that `tanstackStart` uses, and the members
`__executeServer`, `method` and `options` of server functions,
builders and middleware, the `extractedFn` and `serverFn` option
fields and `createMiddleware` on the start instance. Exported types that
no public declaration reaches any more are hidden too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orts

`RawStream`, `hydrate`, `json`, `mergeHeaders`,
`defaultSerovalDeserializerPlugins`, `attachRouterServerSsrUtils`,
`transformReadableStreamWithRouter` and
`transformPipeableStreamWithRouter` stayed public because the Start
packages' published declarations re-exported them. With those
re-exports hidden they are tagged `@internal`, together with the types
only they used: `OnRawStreamCallback`, `JsonResponse`, `TsrSsrGlobal`
and `TransformStreamWithRouterOptions`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aths

`paths` does not merge across `extends`, so an e2e project with its own
`~/*` alias that extends `packages/tsconfig.paths.json` loses the map.
The generator now writes the map into every tsconfig under `e2e/` and
`benchmarks/` that extends the map file and defines `paths`, as it
already does for package tsconfigs, and keeps the file's own entries.

The Playwright plugin adds `^compile` to the build targets of a project
whose tsconfig extends the map, since those builds run `tsc` against
`dist-ts`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`getRequestHeaders`, `getRequestUrl` and `getCookies` are no longer in
the published types. Examples and e2e routes use `getRequest().headers`
and `new URL(getRequest().url)`. The Supabase examples parse the cookie
header with `parseCookieHeader` from `@supabase/ssr`, since their
`getAll` needs every cookie and the documented `getCookie` reads one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ernal types

These projects test names that left the published types: the response
helpers (response-reconciliation, session-handling), `RawStream` (the
basic projects, serialization-adapters, static-server-functions and the
server-fn-transport benchmarks), `getRouterInstance` (the basic and
server-functions projects) and `configureHydrationSuppressions`
(vue-start basic). Their tsconfigs extend `packages/tsconfig.paths.json`;
the e2e projects keep their `~/*` alias, so the generator writes the
map into their `paths`. Their type checks now depend on `compile`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… types

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 92c9b39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@tanstack/start-client-core Patch
@tanstack/start-server-core Patch
@tanstack/start-plugin-core Patch
@tanstack/start-storage-context Patch
@tanstack/react-start Patch
@tanstack/solid-start Patch
@tanstack/vue-start Patch
@tanstack/react-start-client Patch
@tanstack/solid-start-client Patch
@tanstack/vue-start-client Patch
@tanstack/react-start-rsc Patch
@tanstack/router-core Patch
@tanstack/start-static-server-functions Patch
@tanstack/react-start-server Patch
@tanstack/solid-start-server Patch
@tanstack/vue-start-server Patch
@tanstack/react-router Patch
@tanstack/router-generator Patch
@tanstack/router-plugin Patch
@tanstack/solid-router Patch
@tanstack/vue-router Patch
@tanstack/router-cli Patch
@tanstack/router-vite-plugin Patch

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

@nx-cloud

nx-cloud Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 92c9b39

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 5m 26s View ↗

💡 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 2026-11-30 03:46:53 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

21 package(s) bumped directly, 8 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/history 1.162.5 → 1.162.6 Changeset
@tanstack/react-router 1.170.46 → 1.170.47 Changeset
@tanstack/react-router-devtools 1.167.4 → 1.167.5 Changeset
@tanstack/react-start 1.170.0 → 1.170.1 Changeset
@tanstack/react-start-client 1.168.45 → 1.168.46 Changeset
@tanstack/react-start-rsc 0.1.69 → 0.1.70 Changeset
@tanstack/router-core 1.171.39 → 1.171.40 Changeset
@tanstack/router-devtools-core 1.168.4 → 1.168.5 Changeset
@tanstack/router-plugin 1.170.0 → 1.170.1 Changeset
@tanstack/solid-router 1.170.43 → 1.170.44 Changeset
@tanstack/solid-router-devtools 1.167.4 → 1.167.5 Changeset
@tanstack/solid-start 1.170.0 → 1.170.1 Changeset
@tanstack/solid-start-client 1.168.42 → 1.168.43 Changeset
@tanstack/start-client-core 1.170.39 → 1.170.40 Changeset
@tanstack/start-plugin-core 1.173.0 → 1.173.1 Changeset
@tanstack/start-server-core 1.169.45 → 1.169.46 Changeset
@tanstack/start-storage-context 1.167.41 → 1.167.42 Changeset
@tanstack/vue-router 1.170.42 → 1.170.43 Changeset
@tanstack/vue-router-devtools 1.167.4 → 1.167.5 Changeset
@tanstack/vue-start 1.170.0 → 1.170.1 Changeset
@tanstack/vue-start-client 1.167.45 → 1.167.46 Changeset
@tanstack/react-start-server 1.167.52 → 1.167.53 Dependent
@tanstack/router-cli 1.168.1 → 1.168.2 Dependent
@tanstack/router-devtools 1.167.4 → 1.167.5 Dependent
@tanstack/router-generator 1.169.0 → 1.169.1 Dependent
@tanstack/router-vite-plugin 1.167.50 → 1.167.51 Dependent
@tanstack/solid-start-server 1.167.50 → 1.167.51 Dependent
@tanstack/start-static-server-functions 1.167.44 → 1.167.45 Dependent
@tanstack/vue-start-server 1.167.50 → 1.167.51 Dependent

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 309d8e2fcbbd
  • Measured at: 2026-11-30T03:31:48.398Z
  • Baseline source: history:a47dc36d0310
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 84.0 KiB
-15 B
83.9 KiB
-14 B
261.5 KiB
-25 B
73.3 KiB
-39 B
▁▆▆▆▆▆▆▆▆██▄
react-router.full 87.5 KiB
-73 B
87.4 KiB
-72 B
273.2 KiB
-219 B
76.5 KiB
+84 B
▅▇▇▇▇▇▇▇▇██▁
solid-router.minimal 33.4 KiB
-13 B
33.2 KiB
-12 B
95.3 KiB
-25 B
30.2 KiB
-43 B
▁██████████▆
solid-router.full 38.2 KiB
-83 B
38.1 KiB
-82 B
109.9 KiB
-213 B
34.5 KiB
-99 B
▆██████████▁
vue-router.minimal 49.5 KiB
-12 B
49.3 KiB
-11 B
136.5 KiB
-50 B
44.8 KiB
-8 B
▁██████████▆
vue-router.full 55.0 KiB
-72 B
54.9 KiB
-71 B
154.4 KiB
-250 B
49.6 KiB
-51 B
▃██████████▁
react-start.minimal 96.8 KiB
-10 B
96.7 KiB
-11 B
302.4 KiB
-25 B
84.1 KiB
-18 B
▁▅▅▅▅▅▅▅▅██▄
react-start.query-integration 104.2 KiB
-14 B
104.1 KiB
-12 B
329.0 KiB
-25 B
90.6 KiB
+53 B
▁▅▅▅▅▅▅▅▅██▄
react-start.deferred-hydration 97.5 KiB
-12 B
96.7 KiB
-11 B
303.8 KiB
-25 B
84.7 KiB
-130 B
▁▆▆▆▆▆▆▆▆██▆
react-start.full 99.8 KiB
-76 B
99.7 KiB
-73 B
311.5 KiB
-218 B
86.7 KiB
-89 B
▆▇▇▇▇▇▇▇▇██▁
react-start.rsbuild.minimal 96.7 KiB
-13 B
96.5 KiB
-13 B
298.3 KiB
-25 B
83.5 KiB
-26 B
▇█████████▅▁
react-start.rsbuild.minimal-iife 97.1 KiB
-14 B
96.9 KiB
-14 B
299.2 KiB
-25 B
83.7 KiB
-103 B
▆█████████▅▁
react-start.rsbuild.full 99.9 KiB
-87 B
99.7 KiB
-87 B
307.7 KiB
-229 B
86.0 KiB
-126 B
██████████▇▁
solid-start.minimal 46.2 KiB
-11 B
46.1 KiB
-12 B
135.1 KiB
-25 B
41.1 KiB
-106 B
▁██████████▇
solid-start.deferred-hydration 49.2 KiB
-10 B
46.1 KiB
-12 B
142.4 KiB
-25 B
43.9 KiB
-35 B
▁██████████▇
solid-start.full 51.1 KiB
-113 B
51.0 KiB
-110 B
149.8 KiB
-322 B
45.3 KiB
-125 B
▄██████████▁
vue-start.minimal 65.4 KiB
-14 B
65.3 KiB
-13 B
185.7 KiB
-50 B
58.3 KiB
-36 B
▁██████████▆
vue-start.full 69.1 KiB
-84 B
69.0 KiB
-84 B
197.4 KiB
-245 B
61.5 KiB
-151 B
▃██████████▁

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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@9036

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@9036

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@9036

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@9036

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@9036

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@9036

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@9036

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@9036

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@9036

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@9036

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@9036

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@9036

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@9036

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@9036

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@9036

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@9036

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@9036

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@9036

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@9036

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@9036

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@9036

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@9036

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@9036

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@9036

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@9036

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@9036

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@9036

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@9036

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@9036

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@9036

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@9036

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@9036

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@9036

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@9036

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@9036

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@9036

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@9036

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@9036

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@9036

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@9036

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@9036

commit: 92c9b39

@codspeed

codspeed Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.4%

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.

2 warnings, 1 note

⚠️ 57 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 17 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

❌ 2 regressed benchmarks
✅ 198 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory mem client preload-churn (vue) 77.3 KB 81.5 KB -5.1%
❌ Memory mem client unique-location-churn (react) 73.9 KB 76.7 KB -3.69%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing refactor/hide-start-internals (92c9b39) with refactor/hide-router-internals (c8c9241)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant