Skip to content

Conversation

Aneesh-382005
Copy link

Fixes an issue where running npm run dev on Windows would add duplicate entries to tsconfig.json's include array - one with backslashes (.next\dev/types/**/*.ts) and one with forward slashes (.next/dev/types/**/*.ts).

The fix normalizes all paths to POSIX-style (forward slashes) using path.posix and deduplicates the nextAppTypes array using a Set before adding entries to tsconfig.json.

This solution is cross-platform compatible and works consistently on Windows, macOS, and Linux.

For Contributors

Fixing a bug

  • Related issues linked using fixes #number
  • Tests added - existing test suite (writeConfigurationDefaults.test.ts) covers this functionality and passes
  • Errors have a helpful link attached (N/A - no new errors introduced)

What?

This PR fixes a Windows-specific bug where duplicate TypeScript config entries were added to tsconfig.json's include array during npm run dev.

Why?

On Windows, the distDir path separator handling caused the same logical path to appear twice in different formats:

  • .next\dev/types/**/*.ts (mixed separators from Windows path operations)
  • .next/dev/types/**/*.ts (POSIX-style from string templates)

This resulted in duplicate console log messages and duplicate entries in the tsconfig, confusing users.

Changes:

  • Modified packages/next/src/lib/typescript/writeConfigurationDefaults.ts
  • No breaking changes
  • No new dependencies
  • Existing tests pass

Before: Duplicate lines added to tsconfig.json

Console message:

We detected TypeScript in your project and reconfigured your tsconfig.json file for you.
The following suggested values were added to your tsconfig.json. These values can be changed to fit your project's needs:

        - include was updated to add '.next\dev/types/**/*.ts'
        - include was updated to add '.next\dev/types/**/*.ts'
Screenshot 2025-10-18 143141

After: tsconfig.json contains single deduplicated path

Screenshot 2025-10-18 192923

How?

The fix adds path normalization and deduplication in writeConfigurationDefaults.ts:

  1. Path Normalization: Added toPosix() helper that converts all paths to POSIX-style (forward slashes) using path.posix.sep
  2. Deduplication: Use Set to remove duplicate entries before adding to tsconfig
  3. Cross-platform: Works on Windows, macOS, and Linux since TypeScript accepts POSIX paths on all platforms

Closes NEXT-
Fixes #85028

-->

…dows

Fixes an issue where running 'npm run dev' on Windows would add duplicate entries to tsconfig.json's include array - one with backslashes (.next\dev/types/**/*.ts) and one with forward slashes (.next/dev/types/**/*.ts).

The fix normalizes all paths to POSIX-style (forward slashes) using path.posix and deduplicates the nextAppTypes array using a Set before adding entries to tsconfig.json.

This solution is cross-platform compatible and works consistently on Windows, macOS, and Linux.
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.

duplicate type in tsconfig for ".next/dev/types/**/*.ts"

1 participant