fix(tsconfig.json): prevent duplicate tsconfig include entries on Windows#85053
Closed
Aneesh-382005 wants to merge 3 commits into
Closed
fix(tsconfig.json): prevent duplicate tsconfig include entries on Windows#85053Aneesh-382005 wants to merge 3 commits into
Aneesh-382005 wants to merge 3 commits into
Conversation
…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.
Member
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Author
|
Closing this PR to clean up the commit history — will reopen a fresh one with the same fix rebased on the latest canary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where running
npm run devon 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.posixand deduplicates thenextAppTypesarray 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
fixes #numberwriteConfigurationDefaults.test.ts) covers this functionality and passesWhat?
This PR fixes a Windows-specific bug where duplicate TypeScript config entries were added to
tsconfig.json'sincludearray duringnpm run dev.Why?
On Windows, the
distDirpath 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:
packages/next/src/lib/typescript/writeConfigurationDefaults.tsBefore: Duplicate lines added to tsconfig.json
Console message:
After: tsconfig.json contains single deduplicated path
How?
The fix adds path normalization and deduplication in
writeConfigurationDefaults.ts:toPosix()helper that converts all paths to POSIX-style (forward slashes) usingpath.posix.sepSetto remove duplicate entries before adding to tsconfigCloses NEXT-
Fixes #85028
-->