Skip to content

fix(tsconfig.json): prevent duplicate tsconfig include entries on Windows#85053

Closed
Aneesh-382005 wants to merge 3 commits into
vercel:canaryfrom
Aneesh-382005:fix/windows-tsconfig-duplicate
Closed

fix(tsconfig.json): prevent duplicate tsconfig include entries on Windows#85053
Aneesh-382005 wants to merge 3 commits into
vercel:canaryfrom
Aneesh-382005:fix/windows-tsconfig-duplicate

Conversation

@Aneesh-382005
Copy link
Copy Markdown

@Aneesh-382005 Aneesh-382005 commented Oct 19, 2025

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.
@ijjk
Copy link
Copy Markdown
Member

ijjk commented Oct 19, 2025

Allow CI Workflow Run

  • approve CI run for commit: c7d98ca

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@Aneesh-382005
Copy link
Copy Markdown
Author

Closing this PR to clean up the commit history — will reopen a fresh one with the same fix rebased on the latest canary.

@github-actions github-actions Bot added the locked label Nov 2, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants