From 23b9be7b37c40f8c29f9ce50439ad0e25b85282c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 1 Apr 2023 10:04:56 -0400 Subject: fix(check): ensure diagnostics caused by changes in other files get invalidated between runs (#18541) Regression caused by the performance improvement in #18329. Figuring this out was hard. It's luckily still fast after this change. Closes #18516 --- cli/tsc/99_main_compiler.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cli/tsc') diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index b8189278c..2f565770c 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -824,6 +824,23 @@ delete Object.prototype.__proto__; return sourceFile; }) : undefined; + + if (checkFiles != null) { + // When calling program.getSemanticDiagnostics(...) with a source file, we + // need to call this code first in order to get it to invalidate cached + // diagnostics correctly. This is what program.getSemanticDiagnostics() + // does internally when calling without any arguments. + const checkFileNames = new Set(checkFiles.map((f) => f.fileName)); + while ( + program.getSemanticDiagnosticsOfNextAffectedFile( + undefined, + /* ignoreSourceFile */ (s) => !checkFileNames.has(s.fileName), + ) + ) { + // keep going until there are no more affected files + } + } + const diagnostics = [ ...program.getConfigFileParsingDiagnostics(), ...(checkFiles == null -- cgit v1.2.3