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
This commit is contained in:
David Sherret 2023-04-01 10:04:56 -04:00 committed by GitHub
parent c162647020
commit 23b9be7b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 69 deletions

View file

@ -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