fix(router-generator): scaffold plain TypeScript routes without JSX #8481
main fromrefs/pull/8481/head·opened 🎯 Changes#
Fixes #8480.
Creating an empty .ts file within the routes folder broke all route generation with the error: SyntaxError: Missing semicolon. (8:19).
The generator scaffolds empty route files with the target's built in template, which for React & Solid includes a JSX hello world component. This then fails to parse for plain TypeScript files due to Babel's jsx plugin being omitted for .ts filenames. This throws an error before the file is written, so the route file remains empty, and the route tree isn't generated until the file is deleted or populated by hand.
This change opts to scaffold plain TypeScript files with no component instead. A .ts route file is almost always a server route, and a component cannot be added without renaming to .tsx anyway:
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/api/foo')({})
- Added an
optsargument totemplate()and the root route'stsrImports(), which includesallowJsx, when this is false the JSX is dropped, and also the root route'sOutletimport as it would be unused. - Vue and user configured custom scaffolding have been left as is.
- Added
typescript-server-routetest, housing an emptyfoo.tsandfoobar.lazy.tsalongside some.tsxroutes. This test fails onmainwith the semicolon error above. - Added
typescript-root-routetest, has an empty__root.tsjust to cover the empty root case. - I followed the
tests.test-d.tsconvention from thenestedtests, as I had some TypeScript errors due to it not type-checking against the generated route tree. - Copied across the
isPlainTypeScriptFileutil fromrouter-utilsrather than exporting it.
✅ 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).
Summary by CodeRabbit#
- Bug Fixes
- Fixed route generation failures caused by empty
.tsroute files. Generated plain TypeScript routes now use JSX-free scaffolding, while JSX-capable file extensions retain JSX templates.
- Fixed route generation failures caused by empty
- 1
View your CI Pipeline Execution ↗ for commit 4cdb33e62677fae9e3ed97df0f00f7b7a1df65bd
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 19m 21s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2m 10s View ↗
☁️ Nx Cloud last updated this comment at
2026-09-23 16:15:54UTCMore templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@8481@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8481@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8481@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@8481@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8481@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@8481@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@8481@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8481@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@8481@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@8481@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@8481@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@8481@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@8481@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@8481@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@8481@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@8481@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@8481@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@8481@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8481@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@8481@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8481@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@8481@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8481@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8481@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@8481@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@8481@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@8481@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@8481@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8481@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@8481@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@8481@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8481@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@8481@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@8481@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8481@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@8481@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8481@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8481@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@8481@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@8481@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@8481@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@8481commit:
4cdb33eMerging this PR will not alter performance#
✅ 189untouched benchmarks⏩ 3skipped benchmarks1
Comparingnathan-logan:fix/router-generator-plain-ts-route-scaffolding(4cdb33e) withmain(fe7f1fd)Footnotes#
-
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. ↩
-
Nx Cloud has identified a flaky task in your failed CI:#
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
View detailed reasoning in Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)any updates on this?
nathan-logan(GitHub profile, opens in a new tab) linked this to fix #8480
Sign in to join this conversation.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: TanStack/router/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
ec3ac263-68b7-4416-9ec7-6355519b1f76📥 Commits
Reviewing files that changed from the base of the PR and between fe7f1fd0e6ef73c3f341dd2338b406749538a85d and 4cdb33e62677fae9e3ed97df0f00f7b7a1df65bd.
📒 Files selected for processing (19)
.changeset/router-generator-ts-scaffolding.mdpackages/router-generator/src/generator.tspackages/router-generator/src/template.tspackages/router-generator/src/utils.tspackages/router-generator/tests/generator.test.tspackages/router-generator/tests/generator/typescript-root-route/routeTree.snapshot.tspackages/router-generator/tests/generator/typescript-root-route/routes/__root.tspackages/router-generator/tests/generator/typescript-root-route/snapshots/__root.tspackages/router-generator/tests/generator/typescript-root-route/tests.test-d.tspackages/router-generator/tests/generator/typescript-server-route/routeTree.snapshot.tspackages/router-generator/tests/generator/typescript-server-route/routes/__root.tsxpackages/router-generator/tests/generator/typescript-server-route/routes/api/bar.tsxpackages/router-generator/tests/generator/typescript-server-route/routes/api/foo.tspackages/router-generator/tests/generator/typescript-server-route/routes/api/foobar.lazy.tspackages/router-generator/tests/generator/typescript-server-route/routes/foo.lazy.tsxpackages/router-generator/tests/generator/typescript-server-route/routes/index.tsxpackages/router-generator/tests/generator/typescript-server-route/snapshots/api/foo.tspackages/router-generator/tests/generator/typescript-server-route/snapshots/api/foobar.lazy.tspackages/router-generator/tests/generator/typescript-server-route/tests.test-d.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Route generation now scaffolds plain
.ts,.cts, and.mtsroute files without JSX. React and Solid templates retain JSX for other extensions. New generator tests cover TypeScript route fixtures, generated snapshots, and route tree typechecks.Changes#
Plain TypeScript route scaffolding
packages/router-generator/src/utils.ts,packages/router-generator/src/template.tspackages/router-generator/src/generator.tsallowJsxvalue derived from the route file path.packages/router-generator/tests/generator.test.ts,packages/router-generator/tests/generator/typescript-root-route/*,packages/router-generator/tests/generator/typescript-server-route/*,.changeset/router-generator-ts-scaffolding.mdPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
4cdb3Plain TypeScript routes can be scaffolded without JSX, and component-free root routes still render their children. No merge-blocking issue remains.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#8480] requires valid TypeScript scaffolding for empty.tsroutes. The change addsisPlainTypeScriptFileand passes the resulting JSX mode to React and Solid route templates. When JSX is di…#8480]. The helper, template options, JSX gating, changeset, generator fixtures, snapshots, and type-checking tests all support plain TypeScript route scaffolding or ver…Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 18 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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