---
tags:
  - learning
  - gotcha
related:
  - "[[../specs/2026-05-07-apps-docs-scaffold/spec]]"
  - "[[../learnings/tanstack-router-flat-file-nesting]]"
created: 2026-05-07
---
# Dashboard `tsr generate` is not wired to typecheck — fresh worktrees fail `quality-gate`

`apps/dashboard/src/route-tree.gen.ts` is generated by `@tanstack/router-plugin/vite` during `vite build`/`vite dev`, gitignored, and **not** regenerated by `tsc --noEmit`. The dashboard `typecheck` script runs `tsc` directly, so on any fresh worktree (or after `pnpm clean`) `pnpm run quality-gate` fails with a wall of TS errors against route ids until something has triggered a Vite build first. Pre-existing issue surfaced by spec 2026-05-07-apps-docs-scaffold; not caused by `apps/docs`.

## Context

While bringing up `apps/docs` (PR #19 / spec [[../specs/2026-05-07-apps-docs-scaffold/spec]]) the first run of `pnpm run quality-gate` failed on `@zeno/dashboard:typecheck` with errors like:

```
src/routes/_authed/connectors.github-app.tsx(25,38): error TS2345:
Argument of type '"/_authed/connectors/github-app"' is not assignable to parameter of type 'undefined'.
```

The cause: the rebase brought in main's latest dashboard routes but `apps/dashboard/src/route-tree.gen.ts` (gitignored) was empty/stale, so TanStack Router's typed `Route` registry resolved to `undefined`. Running `pnpm --filter @zeno/dashboard exec tsr generate` once made the gate green; nothing in the dashboard's package scripts triggers it as part of `typecheck`.

## How It Works

- `apps/dashboard/vite.config.ts` registers `TanStackRouterVite({ generatedRouteTree: 'src/route-tree.gen.ts' })`. The plugin is what writes the file.
- The dashboard `package.json` defines `"typecheck": "tsc --noEmit"` and **no** `pretypecheck` hook. `turbo.json`'s `typecheck` task only depends on `^build` (upstream workspaces' build), not on the workspace's own `build`.
- `route-tree.gen.ts` is excluded from biome via `apps/dashboard/src/route-tree.gen.ts` in the root `biome.json`'s `files.includes` ignore list, and from git via the root `.gitignore`. So nothing in CI/version control reminds anyone to regenerate it.
- The same gen path applies to `apps/design/src/route-tree.gen.ts` (also excluded in biome).

Net: any new contributor or worktree must run the dashboard build (or `tsr generate` directly) at least once before quality-gate passes. CI happens to work because release pipelines build before they typecheck.

## How to Apply

- On any fresh `apps/dashboard` install / worktree / `pnpm clean`, run `pnpm --filter @zeno/dashboard exec tsr generate` before `pnpm run quality-gate` — or just `pnpm --filter @zeno/dashboard build` once.
- A real fix would add `"pretypecheck": "tsr generate"` to `apps/dashboard/package.json`, OR change `turbo.json` so `typecheck` depends on the workspace's own `build`. Both are out of scope for any non-dashboard PR but should be flagged when next someone touches dashboard scripts.
- When working in a Next.js / Vite workspace whose typecheck depends on a generated file (route trees, source-of-truth schemas, GraphQL types), explicitly wire a `pre*` script to materialize the file before `tsc` runs — don't rely on the developer remembering.
