Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Empty .ts route file is scaffolded with JSX, breaking all route generation

Open Beginner friendly
#8,480 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
cli, tooling

Research direction

The issue is in the route file generator. Look at the templates for 'react' and 'solid' in the router-generator package, likely in a templates directory. The bug is that an empty .ts file gets a JSX template, which fails to parse. Examine the generator code that selects and writes the template. The fix is to ensure .ts files get a valid TypeScript template, not JSX. Test by running the reproducer steps after making changes.

Written by the indexing model from the issue text.

Description

Which project does this relate to?

Router

Describe the bug

Creating an empty .ts route file breaks all route generation, and it does not recover on subsequent runs.

The react and solid templates both contain a JSX component. The generator then transforms the file it has just written and it fails to parse its own output.

Error: Error transforming route file /src/routes/api/foo.ts: SyntaxError: Missing semicolon. (8:19)
    at /node_modules/.pnpm/@tanstack+router-generator@1.167.38/node_modules/@tanstack/router-generator/dist/cjs/generator.cjs:147:13
    at async Object.generate (/tanstack-start-ts-route-generation/node_modules/.pnpm/@tanstack+router-cli@1.167.38/node_modules/@tanstack/router-cli/dist/cjs/generate.cjs:5:3)
    at async /tanstack-start-ts-route-generation/node_modules/.pnpm/@tanstack+router-cli@1.167.38/node_modules/@tanstack/router-cli/dist/cjs/index.cjs:13:3
[ELIFECYCLE] Command failed with exit code 1.
Complete minimal reproducer

https://github.com/nathan-logan/tanstack-start-ts-route-generation

Steps to Reproduce the Bug
  1. Clone the repo
  2. pnpm install
  3. pnpm generate-routes
  4. Fails with SyntaxError: Missing semicolon. (8:19), foo.ts is empty and routeTree.gen.ts was never written.
Expected behavior

I expected an empty .ts route file to be boilerplated with valid TypeScript. Instead it breaks route generation entirely.

Screenshots or Videos

No response

Platform
  • Router / Start Version: 1.170.38 (router-generator Version: 1.167.38)
  • OS: Linux
  • Browser: N/A
  • Browser Version: N/A
  • Bundler: vite
  • Bundler Version: 8.3.0
  • Node version: v24.13.0
Additional context

I have a fix prepared and can open a PR. Only question is around what a .ts file boilerplate should be, I have opted for createFileRoute('/api/foo')({}) on the grounds that a .ts route is almost always a server route and a component can't be added without renaming to .tsx anyway. I use TanStack quite a bit so would still like to see .ts files supported, in previous versions I would just remove the JSX from the template manually after it was inserted.

Side note: I did find that PR #7872 is also open against template.ts and touches the same code I have, but it is unrelated.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 22h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TanStack/router

All issues in TanStack/router

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.