fix(typegen): include link.d.ts in next-env.d.ts when typedRoutes is enabled#93047
Open
sleitor wants to merge 1 commit into
Open
fix(typegen): include link.d.ts in next-env.d.ts when typedRoutes is enabled#93047sleitor wants to merge 1 commit into
sleitor wants to merge 1 commit into
Conversation
…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
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.
What
When
typedRoutes: trueis configured,next-env.d.tsmust include an import oflink.d.tsfor TypeScript to enforce typed routes. Previously the import was nested inside thestrictRouteTypesconditional block, so it was only emitted whenexperimental.strictRouteTypeswas also enabled.Why
In workspace/monorepo setups TypeScript resolves module augmentations differently — the
import './.next/types/link.d.ts'innext-env.d.tsis required for thenext/linkroute type to be augmented and invalidhrefvalues to be caught bytsc.Fix
Move the
link.d.tsimport to a standalonetypedRoutescheck so it is always included whentypedRoutes: true, regardless ofstrictRouteTypes. Updated unit tests to reflect the new expected output.Fixes #93007