fix(web): an empty path segment is not a window
Some checks failed
deploy / build (push) Has been cancelled
deploy / deploy-api (push) Has been cancelled
deploy / deploy-web (push) Has been cancelled

`tsc -b` in CI caught what `tsc --noEmit` locally did not:

    src/lib/routes.ts(131,3): error TS2322:
      Type '"" | Window | null' is not assignable to type 'Window | null'.

`segment && LEGACY_WINDOWS[segment]` returns `''` for an empty path rather than
falling through to the `?? null`, so the root route's window was typed as the
empty string. Checked explicitly instead.

The real lesson is the command: CI runs `pnpm build`, which is `tsc -b && vite
build`. `tsc --noEmit` resolves a different project graph and `vite build` does
no type checking at all, so running those two is not the same gate and passed
over this. Run `pnpm format:check && pnpm lint && pnpm build` before pushing —
which is what the workflow itself runs, verbatim.

Nothing deployed from the failed run: `deploy-api` and `deploy-web` were both
skipped, so the site stayed on a consistent pair.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jp6a8EDar9ueEhAxzep4V5
This commit is contained in:
2026-09-10 14:46:16 +03:00
parent ef367d5993
commit 2594190869

View File

@@ -128,7 +128,11 @@ function asWindow(segment: string | undefined): WindowName | null {
// A link from before the rename. Resolved here rather than rejected, so an
// address somebody shared still opens the page it named — `href` will then
// write the block count back into the bar.
return (segment && LEGACY_WINDOWS[segment]) ?? null
//
// The empty segment is checked separately rather than leaning on `&&`: that
// form returns `''` for an empty path, which is neither a window nor null.
if (!segment) return null
return LEGACY_WINDOWS[segment] ?? null
}
/**