Skip to content

fix: make Next.js type imports version-agnostic (closes #218)#221

Open
mushan0x0 wants to merge 3 commits into
blomqma:mainfrom
mushan0x0:main
Open

fix: make Next.js type imports version-agnostic (closes #218)#221
mushan0x0 wants to merge 3 commits into
blomqma:mainfrom
mushan0x0:main

Conversation

@mushan0x0

Copy link
Copy Markdown
Contributor

Summary

Fixes #218.

With Next.js 16, TypeScript fails to build projects that consume this package with errors like:

Cannot find module 'next/dist/server/config-shared' or its corresponding type declarations.
Cannot find module 'next/dist/server/web/next-url' or its corresponding type declarations.
Cannot find module 'next/dist/compiled/@edge-runtime/cookies' or its corresponding type declarations.

The root cause is that packages/next-rest-framework/src/app-router/route-operation.ts imports several types from internal Next.js paths under next/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:

  • NextURLNextRequest['nextUrl'] (from next/server).
  • ResponseCookiesNextResponse['cookies'] (from next/server).
  • I18NConfigNonNullable<NextConfig['i18n']> (from next), instead of next/dist/server/config-shared.

Also bumps next in dev/peer dependency ranges to cover 16.x and refreshes the lockfile.

Verification

  • pnpm --filter next-rest-framework lint (i.e. tsc) passes.
  • No more references to 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.

@vercel

vercel Bot commented Apr 17, 2026

Copy link
Copy Markdown

@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.

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.

Compatibility issues with Next 16

1 participant