summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-04-01 10:04:56 -0400
committerGitHub <noreply@github.com>2023-04-01 10:04:56 -0400
commit23b9be7b37c40f8c29f9ce50439ad0e25b85282c (patch)
treef2bea2e8daf5c02113e036fe72010bbc3fb61ff4 /cli/tsc
parentc162647020c26de1d27064b488ca11525f1bc4bf (diff)
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
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/99_main_compiler.js17
1 files changed, 17 insertions, 0 deletions
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