diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7b31d09ad68..59ac93f467e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2008,9 +2008,17 @@ namespace ts { if (filesByName.has(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path - // NOTE: this only makes sense for case-insensitive file systems - if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== getNormalizedAbsolutePath(fileName, currentDirectory)) { - reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); + // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected + if (file && options.forceConsistentCasingInFileNames) { + let inputName = fileName; + const checkedName = file.fileName; + const isRedirect = toPath(checkedName) !== toPath(inputName); + if (isRedirect) { + inputName = getProjectReferenceRedirect(fileName) || fileName; + } + if (getNormalizedAbsolutePath(checkedName, currentDirectory) !== getNormalizedAbsolutePath(inputName, currentDirectory)) { + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + } } // If the file was previously found via a node_modules search, but is now being processed as a root file, diff --git a/tests/projects/sample1/logic/index.ts b/tests/projects/sample1/logic/index.ts index fd6b2106bb8..b100878f9f7 100644 --- a/tests/projects/sample1/logic/index.ts +++ b/tests/projects/sample1/logic/index.ts @@ -2,3 +2,5 @@ import * as c from '../core/index'; export function getSecondsInDay() { return c.multiply(10, 15); } +import * as mod from '../core/anotherModule'; +export const m = mod; diff --git a/tests/projects/sample1/logic/tsconfig.json b/tests/projects/sample1/logic/tsconfig.json index a58b3a9f48e..43c78ea4e96 100644 --- a/tests/projects/sample1/logic/tsconfig.json +++ b/tests/projects/sample1/logic/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "composite": true, - "declaration": true + "declaration": true, + "forceConsistentCasingInFileNames": true }, "references": [ { "path": "../core" } diff --git a/tests/projects/sample1/tests/index.ts b/tests/projects/sample1/tests/index.ts index f89dcd08a82..09e1c1476c2 100644 --- a/tests/projects/sample1/tests/index.ts +++ b/tests/projects/sample1/tests/index.ts @@ -3,3 +3,6 @@ import * as logic from '../logic/index'; c.leftPad("", 10); logic.getSecondsInDay(); + +import * as mod from '../core/anotherModule'; +export const m = mod; diff --git a/tests/projects/sample1/tests/tsconfig.json b/tests/projects/sample1/tests/tsconfig.json index 437d8ca6fb3..c686b3824ab 100644 --- a/tests/projects/sample1/tests/tsconfig.json +++ b/tests/projects/sample1/tests/tsconfig.json @@ -3,5 +3,10 @@ { "path": "../core" }, { "path": "../logic" } ], - "files": ["index.ts"] + "files": ["index.ts"], + "compilerOptions": { + "composite": true, + "declaration": true, + "forceConsistentCasingInFileNames": true + } } \ No newline at end of file