Skip to content

Type issues in Next 15/React 19 project #26

@rik-iso

Description

@rik-iso

Hey,

Seeing some type issues in my project:

given:

async function middleware(request: ChainNextRequest): Promise<ChainNextResponse> {
  ...
  return NextResponse.next() // fails with below
}
Type 'NextResponse<unknown>' is not assignable to type 'ChainNextResponse'.
  Type 'NextResponse<unknown>' is not assignable to type 'NextResponse<unknown> & { [FinalSymbol]?: undefined; }'.
    Property '[INTERNALS]' is missing in type 'import("/Users/rik/iso/Code/district/node_modules/.pnpm/next@15.1.7_@babel+core@7.24.6_@opentelemetry+api@1.9.0_babel-plugin-react-compiler@19.0.0-be_iwef3ria7cfvs2ks2iih7m4hgy/node_modules/next/dist/server/web/spec-extension/response").NextResponse<unknown>' but required in type 'import("/Users/rik/iso/Code/3p/nimpl-middleware-chain/node_modules/.pnpm/next@15.1.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/web/spec-extension/response").NextResponse<unknown>'.ts(2322)
response.d.ts(11, 5): '[INTERNALS]' is declared here.

given:

async function middleware(request: NextRequest): Promise<NextResponse> { ... }
export const chainItem: ChainItem = [
  middleware, // fails with below
  {
    include: /^\/m\//,
  },
]
Type '(request: NextRequest) => Promise<NextResponse<unknown>>' is not assignable to type 'Middleware'.
  Types of parameters 'request' and 'req' are incompatible.
    Property '[INTERNALS]' is missing in type 'ChainNextRequest' but required in type 'NextRequest'.ts(2322)

I think this is probably a Next 15/R19 issue but a cursory attempt to bump the Next version to 15 in this package locally didn't seem to work for some reason.

Seems to be fixable if I change my middleware request parameter to request: ChainNextRequest - this is fine but just making sure there's not an underlying incompatibility.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions