nextjs - ✅(Solved) Fix Next.js generates type errors [1 pull requests, 1 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#91895Fetched 2026-04-08 01:30:08
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
1
Participants
Timeline (top)
subscribed ×3issue_type_added ×1labeled ×1

Error Message

https://github.com/remcohaszing/next-type-error git clone https://github.com/remcohaszing/next-type-error.git cd next-type-error .next/dev/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife .next/dev/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'. .next/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife .next/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'.

PR fix notes

PR #4: add ai voice assistant

Description (problem / solution / changelog)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

  • New Features

    • Added voice call integration to the widget with call control buttons and real-time connection/speaking status indicators.
    • Implemented transcript display showing live conversation messages.
  • Chores

    • Updated build configuration references.
    • Added voice communication library dependency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Changed files

  • apps/web/next-env.d.ts (modified, +1/-1)
  • apps/widget/app/page.tsx (modified, +21/-7)
  • apps/widget/modules/widget/hooks/use-vapi.ts (added, +88/-0)
  • apps/widget/next-env.d.ts (modified, +1/-1)
  • apps/widget/package.json (modified, +1/-0)
  • pnpm-lock.yaml (modified, +87/-0)

Code Example

git clone https://github.com/remcohaszing/next-type-error.git
cd next-type-error
npm install
npx next typegen
npx next dev

---

npx tsc

---

$ npx tsc
.next/dev/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife

3 declare module 'next/cache' {
  ~~~~~~~

  .next/types/cache-life.d.ts:3:1
    3 declare module 'next/cache' {
      ~~~~~~~
    Conflicts are in this file.

.next/dev/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'.

50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
          ~~~~~~~~~~~

  .next/types/routes.d.ts:50:8
    50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
              ~~~~~~~~~~~
    'LayoutProps' was also declared here.

.next/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife

3 declare module 'next/cache' {
  ~~~~~~~

  .next/dev/types/cache-life.d.ts:3:1
    3 declare module 'next/cache' {
      ~~~~~~~
    Conflicts are in this file.

.next/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'.

50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
          ~~~~~~~~~~~

  .next/dev/types/routes.d.ts:50:8
    50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
              ~~~~~~~~~~~
    'LayoutProps' was also declared here.


Found 4 errors in 4 files.

Errors  Files
     1  .next/dev/types/cache-life.d.ts:3
     1  .next/dev/types/routes.d.ts:50
     1  .next/types/cache-life.d.ts:3
     1  .next/types/routes.d.ts:50

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #202601231045~1769703228~24.04~cb87b5b SMP PREEMPT_DYNAMIC Thu J
  Available memory (MB): 31804
  Available CPU cores: 12
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: 1.22.22
  pnpm: 9.14.4
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 6.0.2
Next.js Config:
  output: N/A

---

declare module 'next' {
  export interface AppRoutesMap {
    '/': {}
    // …
  }

  // …
}

---

export interface AppRoutesMap {}
// …

export type AppRoutes = keyof[AppRoutesMap]
// …

declare global {
  // …
}

---

import type {
  AppRouteHandlerRoutes,
  AppRoutes,
  LayoutRoutes,
  PageRoutes,
  ParamMap,
  ParamsOf,
  RedirectRoutes,
  RewriteRoutes,
} from 'next'
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/remcohaszing/next-type-error

To Reproduce

git clone https://github.com/remcohaszing/next-type-error.git
cd next-type-error
npm install
npx next typegen
npx next dev

Stop the dev server.

Now type check the repo:

npx tsc

Current vs. Expected behavior

I expected there to be no type errors. But instead, there are type errors in the generated types.

$ npx tsc
.next/dev/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife

3 declare module 'next/cache' {
  ~~~~~~~

  .next/types/cache-life.d.ts:3:1
    3 declare module 'next/cache' {
      ~~~~~~~
    Conflicts are in this file.

.next/dev/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'.

50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
          ~~~~~~~~~~~

  .next/types/routes.d.ts:50:8
    50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
              ~~~~~~~~~~~
    'LayoutProps' was also declared here.

.next/types/cache-life.d.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: unstable_cache, updateTag, revalidateTag, revalidatePath, refresh, unstable_noStore, cacheTag, unstable_cacheTag, unstable_cacheLife

3 declare module 'next/cache' {
  ~~~~~~~

  .next/dev/types/cache-life.d.ts:3:1
    3 declare module 'next/cache' {
      ~~~~~~~
    Conflicts are in this file.

.next/types/routes.d.ts:50:8 - error TS2300: Duplicate identifier 'LayoutProps'.

50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
          ~~~~~~~~~~~

  .next/dev/types/routes.d.ts:50:8
    50   type LayoutProps<LayoutRoute extends LayoutRoutes> = {
              ~~~~~~~~~~~
    'LayoutProps' was also declared here.


Found 4 errors in 4 files.

Errors  Files
     1  .next/dev/types/cache-life.d.ts:3
     1  .next/dev/types/routes.d.ts:50
     1  .next/types/cache-life.d.ts:3
     1  .next/types/routes.d.ts:50

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202601231045~1769703228~24.04~cb87b5b SMP PREEMPT_DYNAMIC Thu J
  Available memory (MB): 31804
  Available CPU cores: 12
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: 1.22.22
  pnpm: 9.14.4
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 6.0.2
Next.js Config:
  output: N/A

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

TypeScript

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

next dev (local), next build (local), next start (local)

Additional context

By default Next.js enables the TypeScript option skipLibCheck. skipLibCheck hides errors from declaration files, meaning these errors are typically hidden from users. These errors may still cause problems though.

For example, routes.d.ts exports some types which are useful for users to import. which file should users import these from? .next/types/routes.d.ts or .next/dev/types/routes.d.ts? What if the imports are mixed and they don’t match up in some states?

This can be solved with module/interface augmentation.

declare module 'next' {
  export interface AppRoutesMap {
    '/': {}
    // …
  }

  // …
}

Then in the next types:

export interface AppRoutesMap {}
// …

export type AppRoutes = keyof[AppRoutesMap]
// …

declare global {
  // …
}

Now users can just import everything from next

import type {
  AppRouteHandlerRoutes,
  AppRoutes,
  LayoutRoutes,
  PageRoutes,
  ParamMap,
  ParamsOf,
  RedirectRoutes,
  RewriteRoutes,
} from 'next'

But also, ideally just don’t generate duplicate types.

extent analysis

Fix Plan

To resolve the type errors, we need to prevent duplicate type declarations. We can achieve this by using module augmentation to extend the existing types instead of re-declaring them.

Here are the steps:

  • Stop the dev server.
  • Remove the duplicate type declarations from .next/dev/types/cache-life.d.ts and .next/dev/types/routes.d.ts.
  • Use module augmentation to extend the existing types in next.d.ts:
// next.d.ts
declare module 'next/cache' {
  // Add new types here
}

declare module 'next' {
  export interface AppRoutesMap {
    '/': {}
    // …
  }

  // …
}
  • Update the tsconfig.json to include the next.d.ts file:
{
  "compilerOptions": {
    // ...
    "typeRoots": ["node_modules/@types", "./next.d.ts"],
    // ...
  }
}
  • Run npx tsc to verify that the type errors are resolved.

Verification

To verify that the fix worked, run npx tsc and check that there are no type errors. You can also import the types from next without any issues:

import type {
  AppRouteHandlerRoutes,
  AppRoutes,
  LayoutRoutes,
  PageRoutes,
  ParamMap,
  ParamsOf,
  RedirectRoutes,
  RewriteRoutes,
} from 'next'

Extra Tips

To prevent similar issues in the future, make sure to use module augmentation to extend existing types instead of re-declaring them. Also, keep the next.d.ts file up to date with the latest types from next.

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