Skip to content

fix(typegen): include link.d.ts in next-env.d.ts when typedRoutes is enabled#93047

Open
sleitor wants to merge 1 commit into
vercel:canaryfrom
sleitor:fix-93007
Open

fix(typegen): include link.d.ts in next-env.d.ts when typedRoutes is enabled#93047
sleitor wants to merge 1 commit into
vercel:canaryfrom
sleitor:fix-93007

Conversation

@sleitor
Copy link
Copy Markdown
Contributor

@sleitor sleitor commented Apr 20, 2026

What

When typedRoutes: true is configured, next-env.d.ts must include an import of link.d.ts for TypeScript to enforce typed routes. Previously the import was nested inside the strictRouteTypes conditional block, so it was only emitted when experimental.strictRouteTypes was also enabled.

Why

In workspace/monorepo setups TypeScript resolves module augmentations differently — the import './.next/types/link.d.ts' in next-env.d.ts is required for the next/link route type to be augmented and invalid href values to be caught by tsc.

Fix

Move the link.d.ts import to a standalone typedRoutes check so it is always included when typedRoutes: true, regardless of strictRouteTypes. Updated unit tests to reflect the new expected output.

Fixes #93007

…enabled

When typedRoutes: true is configured, next-env.d.ts must include
link.d.ts for TypeScript to enforce typed routes in workspace/monorepo
setups. Previously the import was nested inside the strictRouteTypes
block so it was only emitted when strictRouteTypes was also enabled.

Move the link.d.ts import to a standalone typedRoutes check so it is
always emitted when typedRoutes: true, regardless of strictRouteTypes.

Fixes vercel#93007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typedRoutes invalid Link href is not enforced by tsc in a workspace app unless .next/types/link.d.ts is manually referenced

1 participant