Skip to content

feat(router-generator): add isolatedDeclarations option - #12

Closed
guru-irl wants to merge 11 commits into
mainfrom
feat/router-generator-isolated-declarations-exact
Closed

guru-irl wants to merge 11 commits into
mainfrom
feat/router-generator-isolated-declarations-exact

Conversation

@guru-irl

@guru-irl guru-irl commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

🎯 Changes

AI disclosure: an AI coding agent wrote the code, the tests and this description.

Motivation

  • With isolatedDeclarations, declaration emit needs an explicit type on every declaration that ends up in a .d.ts file. Tools such as oxc rely on this to emit declarations one file at a time.
  • The generated route tree has no annotations. Its exported interfaces refer to each route const (typeof PostsRoute), and routeTree itself is exported. So with isolatedDeclarations on, tsc 6.0 and 7.0 report TS9010 for every route const and for routeTree, even though the file starts with // @ts-nocheck.

Changes

  • Adds an isolatedDeclarations option to the generator, off by default. Turn it on in tsr.config.json or in the bundler plugin's options, for example tanstackRouter({ isolatedDeclarations: true }).
  • With the option on, the generator gives each const in the route tree an explicit type annotation. Each annotation names the type TypeScript already infers, so the route types stay exact.
  • The generator can't write an exact annotation for a virtual route, such as a lazy file without a route file, so it types that route as any. Adding a route file for the path keeps its exact type.
  • With the option off, or with disableTypes on, the generated output doesn't change.
  • The option covers only the generated route tree. Route files still need their own annotations.

Tests

  • The generator tests rerun five fixtures with the option on and compare each against a second snapshot, routeTree.isolated.snapshot.ts: nested, lazy, lazy-only routes (typed as any), Vue root components (the one new fixture), and disableTypes, whose output must not change.
  • isolated-declarations.test.ts compiles the nested and lazy snapshots with isolatedDeclarations on. The annotated tree has no errors, the plain tree reports TS9010, and both trees have the same type.
  • Passing locally: pnpm test:eslint, pnpm test:types and pnpm test:unit from the repo root.

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

@github-actions github-actions Bot added documentation Improvements or additions to documentation package: router-generator labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/router-generator 1.167.46 → 1.167.47 Changeset
@tanstack/react-start 1.169.4 → 1.169.5 Dependent
@tanstack/react-start-rsc 0.1.65 → 0.1.66 Dependent
@tanstack/router-cli 1.167.46 → 1.167.47 Dependent
@tanstack/router-plugin 1.168.48 → 1.168.49 Dependent
@tanstack/router-vite-plugin 1.167.48 → 1.167.49 Dependent
@tanstack/solid-start 1.169.4 → 1.169.5 Dependent
@tanstack/start-plugin-core 1.171.55 → 1.171.56 Dependent
@tanstack/vue-start 1.169.4 → 1.169.5 Dependent

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Bundle Size Benchmarks

  • Commit: bae2cbb491fd
  • Measured at: 2026-10-30T09:03:57.251Z
  • Baseline source: history:d6decca41807
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes or lack baseline data for comparison:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 84.0 KiB
-3.3 KiB
83.9 KiB
n/a
261.5 KiB
-13.2 KiB
73.3 KiB
-2.5 KiB
███████████▁
react-router.full 87.6 KiB
-3.2 KiB
87.4 KiB
n/a
273.3 KiB
-12.8 KiB
76.4 KiB
-2.6 KiB
███████████▁
solid-router.minimal 33.3 KiB
-2.2 KiB
33.2 KiB
n/a
95.2 KiB
-11.7 KiB
30.2 KiB
-1.8 KiB
███████████▁
solid-router.full 38.3 KiB
-2.0 KiB
38.1 KiB
n/a
110.0 KiB
-11.1 KiB
34.5 KiB
-1.7 KiB
███████████▁
vue-router.minimal 49.4 KiB
-3.9 KiB
49.3 KiB
n/a
136.5 KiB
-15.6 KiB
44.8 KiB
-3.1 KiB
███████████▁
vue-router.full 55.0 KiB
-3.4 KiB
54.9 KiB
n/a
154.6 KiB
-13.6 KiB
49.7 KiB
-2.6 KiB
███████████▁
react-start.minimal 96.8 KiB
-5.1 KiB
96.7 KiB
n/a
302.4 KiB
-20.5 KiB
84.1 KiB
-3.9 KiB
███████████▁
react-start.query-integration 104.2 KiB
n/a
104.1 KiB
n/a
329.0 KiB
n/a
90.5 KiB
n/a
▅
react-start.deferred-hydration 97.5 KiB
n/a
96.7 KiB
n/a
303.7 KiB
n/a
84.7 KiB
n/a
▅
react-start.full 99.9 KiB
-5.5 KiB
99.7 KiB
n/a
311.6 KiB
-21.5 KiB
86.6 KiB
-4.4 KiB
███████████▁
react-start.rsbuild.minimal 100.3 KiB
-1.1 KiB
100.2 KiB
n/a
313.3 KiB
-12.5 KiB
86.6 KiB
-503 B
███████████▁
react-start.rsbuild.minimal-iife 100.8 KiB
n/a
100.6 KiB
n/a
314.2 KiB
n/a
87.0 KiB
n/a
▅
react-start.rsbuild.full 103.5 KiB
-1.2 KiB
103.4 KiB
n/a
322.9 KiB
-13.6 KiB
89.4 KiB
-508 B
███████████▁
solid-start.minimal 46.2 KiB
-3.4 KiB
46.0 KiB
n/a
135.1 KiB
-17.7 KiB
41.1 KiB
-2.5 KiB
███████████▁
solid-start.deferred-hydration 49.2 KiB
n/a
46.1 KiB
n/a
142.4 KiB
n/a
43.9 KiB
n/a
▅
solid-start.full 51.2 KiB
-4.2 KiB
51.1 KiB
n/a
150.0 KiB
-19.7 KiB
45.5 KiB
-3.3 KiB
███████████▁
vue-start.minimal 65.4 KiB
n/a
65.3 KiB
n/a
185.7 KiB
n/a
58.4 KiB
n/a
▅
vue-start.full 69.1 KiB
n/a
69.0 KiB
n/a
197.6 KiB
n/a
61.6 KiB
n/a
▅

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.

…arations compile test

The Vue case type-checked vue-router's source, which needs vue-router's own
dependencies installed. Installs that cover only the generator's dependencies
don't have them, so the case failed there. The Vue root-components fixtures
remain snapshot tests, and the compile test counts every diagnostic again.
@guru-irl

Copy link
Copy Markdown
Owner Author

This is an agentic response

Raised upstream as TanStack#8833.

@guru-irl guru-irl closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation package: router-generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant