nextjs - 💡(How to fix) Fix PageConfig type differs from ApiRouteConfig, but the latter is not exported [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#83946Fetched 2026-04-08 02:21:03
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
4
Timeline (top)
subscribed ×4labeled ×2commented ×1cross-referenced ×1

Error Message

.next/types/validator.ts:1389:31 - error TS2344: Type 'typeof import("{{my_project_location}}/src/pages/api/submit/abstract")' does not satisfy the constraint 'ApiRouteConfig'.

Code Example

import {type PageConfig} from 'next';

export const config: PageConfig = {
    api: {
        externalResolver: true,
        bodyParser: false,
    },
};

/// api route handler part

---

.next/types/validator.ts:1389:31 - error TS2344: Type 'typeof import("{{my_project_location}}/src/pages/api/submit/abstract")' does not satisfy the constraint 'ApiRouteConfig'.
  The types of 'config.api' are incompatible between these types.
    Type '{ responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; } | undefined' is not assignable to type '{ bodyParser?: boolean | { sizeLimit?: string | undefined; } | undefined; responseLimit?: string | number | boolean | undefined; externalResolver?: boolean | undefined; } | undefined'.
      Type '{ responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; }' is not assignable to type '{ bodyParser?: boolean | { sizeLimit?: string | undefined; } | undefined; responseLimit?: string | number | boolean | undefined; externalResolver?: boolean | undefined; }'.
        Types of property 'bodyParser' are incompatible.
          Type 'false | { sizeLimit?: SizeLimit | undefined; } | undefined' is not assignable to type 'boolean | { sizeLimit?: string | undefined; } | undefined'.
            Type '{ sizeLimit?: SizeLimit | undefined; }' is not assignable to type 'boolean | { sizeLimit?: string | undefined; } | undefined'.
              Type '{ sizeLimit?: SizeLimit | undefined; }' is not assignable to type '{ sizeLimit?: string | undefined; }'.
                Types of property 'sizeLimit' are incompatible.
                  Type 'SizeLimit | undefined' is not assignable to type 'string | undefined'.
                    Type 'number' is not assignable to type 'string'.

1389   type __Check = __IsExpected<typeof handler>

---

export const config = {
    api: {
        externalResolver: true,
        bodyParser: false,
    },
};

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.19.4
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.5.3 // Latest available version is detected (15.5.3).
  eslint-config-next: 15.3.1
  react: 19.1.1
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/michal-pokojski-nwt/nextjs-api-route-config-repro

To Reproduce

  1. Make pages router api route nextjs 15.5.3
  2. Export from it a config with PageConfig type (no other is available)
  3. Build types with tsc.

example config not working when building types

import {type PageConfig} from 'next';

export const config: PageConfig = {
    api: {
        externalResolver: true,
        bodyParser: false,
    },
};

/// api route handler part

console output

.next/types/validator.ts:1389:31 - error TS2344: Type 'typeof import("{{my_project_location}}/src/pages/api/submit/abstract")' does not satisfy the constraint 'ApiRouteConfig'.
  The types of 'config.api' are incompatible between these types.
    Type '{ responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; } | undefined' is not assignable to type '{ bodyParser?: boolean | { sizeLimit?: string | undefined; } | undefined; responseLimit?: string | number | boolean | undefined; externalResolver?: boolean | undefined; } | undefined'.
      Type '{ responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; }' is not assignable to type '{ bodyParser?: boolean | { sizeLimit?: string | undefined; } | undefined; responseLimit?: string | number | boolean | undefined; externalResolver?: boolean | undefined; }'.
        Types of property 'bodyParser' are incompatible.
          Type 'false | { sizeLimit?: SizeLimit | undefined; } | undefined' is not assignable to type 'boolean | { sizeLimit?: string | undefined; } | undefined'.
            Type '{ sizeLimit?: SizeLimit | undefined; }' is not assignable to type 'boolean | { sizeLimit?: string | undefined; } | undefined'.
              Type '{ sizeLimit?: SizeLimit | undefined; }' is not assignable to type '{ sizeLimit?: string | undefined; }'.
                Types of property 'sizeLimit' are incompatible.
                  Type 'SizeLimit | undefined' is not assignable to type 'string | undefined'.
                    Type 'number' is not assignable to type 'string'.

1389   type __Check = __IsExpected<typeof handler>

example config working when building types

export const config = {
    api: {
        externalResolver: true,
        bodyParser: false,
    },
};

Current vs. Expected behavior

Current behavior: Build types crushes

Expected behavior: Build types passes / ApiRouteConfig is exported and available to be used when type safe api route config is needed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.19.4
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.5.3 // Latest available version is detected (15.5.3).
  eslint-config-next: 15.3.1
  react: 19.1.1
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router, TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

extent analysis

TL;DR

The issue can be resolved by using the correct type for the config object, which is ApiRouteConfig instead of PageConfig, or by removing the type annotation to allow TypeScript to infer the type.

Guidance

  • The error message indicates a type mismatch between the PageConfig type and the ApiRouteConfig type, specifically with the bodyParser property.
  • The working example config suggests that removing the type annotation for the config object allows TypeScript to infer the correct type.
  • To fix the issue, try changing the type annotation from PageConfig to ApiRouteConfig or remove the type annotation altogether.
  • Verify that the build process completes successfully after making the change.

Example

// Remove type annotation
export const config = {
  api: {
    externalResolver: true,
    bodyParser: false,
  },
};

Alternatively, if the ApiRouteConfig type is available, you can use it instead:

import type { ApiRouteConfig } from 'next';

export const config: ApiRouteConfig = {
  api: {
    externalResolver: true,
    bodyParser: false,
  },
};

Notes

The issue seems to be related to a type mismatch between the PageConfig and ApiRouteConfig types. The ApiRouteConfig type is not explicitly imported in the provided code, so it's unclear if it's available. If it's not available, removing the type annotation might be the simplest solution.

Recommendation

Apply workaround: Remove the type annotation for the config object to allow TypeScript to infer the correct type. This should resolve the type mismatch issue and allow the build process to complete successfully.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING