feat(web): typed routes — broken internal links are now compile errors - #115
Merged
Conversation
typedRoutes: true (stable in Next 16; `next typegen` already runs in CI before tsc since #114). A typo'd <Link>/router.push target now fails the build instead of 404ing at runtime — the failure class behind the recent RSC/routing incidents. - lib/routes.ts: registry helpers return `Route`; withQuery validates the base path literal. New: deviceBlockUrl (OpsEventsSection previously hand-built /admin/security/device-block against the registry rule), route() to compile-check dynamic-section literals (nav configs, section index redirects), trustedRoute() as the single named seam for runtime-data hrefs (backend-emitted notification deep links, persisted post-login return URL). - Nav types (NavItem, ExpandableSubItem, PageSectionItem) carry Route hrefs — every sidebar/navbar entry is compile-checked. - ClientRedirect is generic so dynamic-section literals infer. Verified: tsc clean; negative test (typo'd static + dynamic routes) fails compilation as intended; 611/611 vitest; static export builds with an unchanged route list. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
typedRoutes: true(stable in Next 16). A typo''d<Link>/router.pushtarget now fails the build instead of 404ing at runtime — the failure class behind the recent RSC/routing incidents. The CI foundation (next typegenbeforetsc) already ships since #114.lib/routes.tsregistry: helpers returnRoute;withQueryvalidates the base path literal at compile timeroute()— identity helper that compile-checks dynamic[section]literals (nav configs, section index redirects) via type inferencetrustedRoute()— the single named seam for runtime-data hrefs (backend-emitted notification deep links, persisted post-login return URL); no scatteredas RoutecastsdeviceBlockUrl()— OpsEventsSection previously hand-built/admin/security/device-blockagainst the registry ruleNavItem,ExpandableSubItem,PageSectionItem) carryRoutehrefs — every sidebar/navbar entry is compile-checked;ClientRedirectis generic so dynamic-section literals inferVerification
tsc --noEmitclean; negative test: typo''d static AND dynamic routes fail compilation (incl. "Did you mean ''/sessions''?")🤖 Generated with Claude Code