fix: make Next.js type imports version-agnostic (closes #218)#221
Open
mushan0x0 wants to merge 3 commits into
Open
fix: make Next.js type imports version-agnostic (closes #218)#221mushan0x0 wants to merge 3 commits into
mushan0x0 wants to merge 3 commits into
Conversation
|
@mushan0x0 is attempting to deploy a commit to the Markus Blomqvist's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
Fixes #218.
With Next.js 16, TypeScript fails to build projects that consume this package with errors like:
The root cause is that
packages/next-rest-framework/src/app-router/route-operation.tsimports several types from internal Next.js paths undernext/dist/**. Those paths are not part of Next's public API; their layout and exports change between Next versions, so the package breaks whenever Next reorganizes its internals (Next 16 is the latest instance).Changes
In
packages/next-rest-framework/src/app-router/route-operation.ts, replace internal imports with types derived from Next.js's public API, so the package is compatible across Next 13/14/15/16 without depending on internal file structure:NextURL→NextRequest['nextUrl'](fromnext/server).ResponseCookies→NextResponse['cookies'](fromnext/server).I18NConfig→NonNullable<NextConfig['i18n']>(fromnext), instead ofnext/dist/server/config-shared.Also bumps
nextin dev/peer dependency ranges to cover 16.x and refreshes the lockfile.Verification
pnpm --filter next-rest-framework lint(i.e.tsc) passes.next/dist/**in the package's source types, so consumers on Next 13–16 no longer hit the missing-module errors from Compatibility issues with Next 16 #218.