Skip to content

Commit f6d3ac9

Browse files
authored
Fix microsoft#25820 - handle redirected files when comparing paths (microsoft#25902)
* Fix microsoft#25820 - handle redirected files when comparing paths * Update test to do case check
1 parent 870c55c commit f6d3ac9

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

src/compiler/program.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -2008,9 +2008,17 @@ namespace ts {
20082008
if (filesByName.has(path)) {
20092009
const file = filesByName.get(path);
20102010
// try to check if we've already seen this file but with a different casing in path
2011-
// NOTE: this only makes sense for case-insensitive file systems
2012-
if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== getNormalizedAbsolutePath(fileName, currentDirectory)) {
2013-
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
2011+
// NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected
2012+
if (file && options.forceConsistentCasingInFileNames) {
2013+
let inputName = fileName;
2014+
const checkedName = file.fileName;
2015+
const isRedirect = toPath(checkedName) !== toPath(inputName);
2016+
if (isRedirect) {
2017+
inputName = getProjectReferenceRedirect(fileName) || fileName;
2018+
}
2019+
if (getNormalizedAbsolutePath(checkedName, currentDirectory) !== getNormalizedAbsolutePath(inputName, currentDirectory)) {
2020+
reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd);
2021+
}
20142022
}
20152023

20162024
// If the file was previously found via a node_modules search, but is now being processed as a root file,

tests/projects/sample1/logic/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ import * as c from '../core/index';
22
export function getSecondsInDay() {
33
return c.multiply(10, 15);
44
}
5+
import * as mod from '../core/anotherModule';
6+
export const m = mod;

tests/projects/sample1/logic/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
33
"composite": true,
4-
"declaration": true
4+
"declaration": true,
5+
"forceConsistentCasingInFileNames": true
56
},
67
"references": [
78
{ "path": "../core" }

tests/projects/sample1/tests/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ import * as logic from '../logic/index';
33

44
c.leftPad("", 10);
55
logic.getSecondsInDay();
6+
7+
import * as mod from '../core/anotherModule';
8+
export const m = mod;

tests/projects/sample1/tests/tsconfig.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
{ "path": "../core" },
44
{ "path": "../logic" }
55
],
6-
"files": ["index.ts"]
6+
"files": ["index.ts"],
7+
"compilerOptions": {
8+
"composite": true,
9+
"declaration": true,
10+
"forceConsistentCasingInFileNames": true
11+
}
712
}

0 commit comments

Comments
 (0)