Skip to content

Commit 239a7b9

Browse files
committed
better condition for file include exhaustiveness check
As `files` always contains declaration files of external libraries, lib files and declaration files from typeRoots, the previous condition evaluated to false for probably all projects out there. This changes the condition to compare array length after filtering out all declaration files. That avoids unnecessary work of path normalization in the common case where everything is ok.
1 parent 4510149 commit 239a7b9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/compiler/program.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,12 +2432,14 @@ namespace ts {
24322432
}
24332433

24342434
// List of collected files is complete; validate exhautiveness if this is a project with a file list
2435-
if (options.composite && rootNames.length < files.length) {
2436-
const normalizedRootNames = rootNames.map(r => normalizePath(r).toLowerCase());
2437-
const sourceFiles = files.filter(f => !f.isDeclarationFile).map(f => normalizePath(f.path).toLowerCase());
2438-
for (const file of sourceFiles) {
2439-
if (normalizedRootNames.every(r => r !== file)) {
2440-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file));
2435+
if (options.composite) {
2436+
const sourceFiles = files.filter(f => !f.isDeclarationFile);
2437+
if (rootNames.length < sourceFiles.length) {
2438+
const normalizedRootNames = rootNames.map(r => normalizePath(r).toLowerCase());
2439+
for (const file of sourceFiles.map(f => normalizePath(f.path).toLowerCase())) {
2440+
if (normalizedRootNames.indexOf(file) === -1) {
2441+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file));
2442+
}
24412443
}
24422444
}
24432445
}

0 commit comments

Comments
 (0)