Skip to content

Commit 6742e55

Browse files
committed
Fix error reporting to match with strada for case sensitive file system
1 parent 06b18b3 commit 6742e55

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

internal/compiler/filesparser.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
233233
filesByPath := make(map[tspath.Path]*ast.SourceFile, totalFileCount)
234234
// stores 'filename -> file association' ignoring case
235235
// used to track cases when two file names differ only in casing
236-
var filesByNameIgnoreCase map[string]*ast.SourceFile
236+
var tasksSeenByNameIgnoreCase map[string]*parseTask
237237
if loader.comparePathsOptions.UseCaseSensitiveFileNames {
238-
filesByNameIgnoreCase = make(map[string]*ast.SourceFile, totalFileCount)
238+
tasksSeenByNameIgnoreCase = make(map[string]*parseTask, totalFileCount)
239239
}
240240

241241
loader.includeProcessor.fileIncludeReasons = make(map[tspath.Path][]*FileIncludeReason, totalFileCount)
@@ -284,6 +284,15 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
284284
seen[data] = task.normalizedFilePath
285285
}
286286

287+
if tasksSeenByNameIgnoreCase != nil {
288+
pathLowerCase := tspath.ToFileNameLowerCase(string(task.path))
289+
if taskByIgnoreCase, ok := tasksSeenByNameIgnoreCase[pathLowerCase]; ok {
290+
loader.includeProcessor.addProcessingDiagnosticsForFileCasing(taskByIgnoreCase.path, taskByIgnoreCase.normalizedFilePath, task.normalizedFilePath, includeReason)
291+
} else {
292+
tasksSeenByNameIgnoreCase[pathLowerCase] = task
293+
}
294+
}
295+
287296
for _, trace := range task.typeResolutionsTrace {
288297
loader.opts.Host.Trace(trace.Message, trace.Args...)
289298
}
@@ -316,15 +325,6 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
316325
continue
317326
}
318327

319-
if filesByNameIgnoreCase != nil {
320-
pathLowerCase := tspath.ToFileNameLowerCase(string(path))
321-
if existingFile, ok := filesByNameIgnoreCase[pathLowerCase]; ok {
322-
loader.includeProcessor.addProcessingDiagnosticsForFileCasing(path, existingFile.FileName(), file.FileName(), includeReason)
323-
} else {
324-
filesByNameIgnoreCase[pathLowerCase] = file
325-
}
326-
}
327-
328328
if task.libFile != nil {
329329
libFiles = append(libFiles, file)
330330
libFilesMap[path] = task.libFile

testdata/baselines/reference/tsc/forceConsistentCasingInFileNames/two-files-exist-on-disk-that-differs-only-in-casing.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ export const y = 20;
1515
tsgo
1616
ExitStatus:: DiagnosticsPresent_OutputsGenerated
1717
Output::
18-
[91merror[0m[90m TS1149: [0mFile name '/home/src/workspaces/project/d.ts' differs from already included file name '/home/src/workspaces/project/D.ts' only in casing.
18+
[96mc.ts[0m:[93m1[0m:[93m17[0m - [91merror[0m[90m TS1261: [0mAlready included file name '/home/src/workspaces/project/D.ts' differs from file name '/home/src/workspaces/project/d.ts' only in casing.
1919
The file is in the program because:
20+
Imported via "./D" from file '/home/src/workspaces/project/c.ts'
2021
Part of 'files' list in tsconfig.json
22+
23+
1 import {x} from "./D"
24+
   ~~~~~
25+
2126
tsconfig.json:2:23 - File is matched by 'files' list specified here.
2227
2 "files": ["c.ts", "d.ts"]
2328
   ~~~~~~
2429

2530

26-
Found 1 error.
31+
Found 1 error in c.ts[90m:1[0m
2732

2833
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
2934
/// <reference no-default-lib="true"/>

0 commit comments

Comments
 (0)