Skip to content

Commit 43c4478

Browse files
committed
PR feedback
1 parent fdafbd6 commit 43c4478

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/compiler/builder.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace ts {
3939
*/
4040
seenAffectedFiles: Map<true> | undefined;
4141
/**
42-
* program corresponding to this state
42+
* whether this program has cleaned semantic diagnostics cache for lib files
4343
*/
4444
cleanedDiagnosticsOfLibFiles?: boolean;
4545
/**
@@ -68,9 +68,11 @@ namespace ts {
6868
state.semanticDiagnosticsPerFile = createMap<ReadonlyArray<Diagnostic>>();
6969
}
7070
state.changedFilesSet = createMap<true>();
71+
7172
const useOldState = BuilderState.canReuseOldState(state.referencedMap, oldState);
73+
const oldCompilerOptions = useOldState ? oldState!.program.getCompilerOptions() : undefined;
7274
const canCopySemanticDiagnostics = useOldState && oldState!.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
73-
!compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState!.program.getCompilerOptions());
75+
!compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions!);
7476
if (useOldState) {
7577
// Verify the sanity of old state
7678
if (!oldState!.currentChangedFilePath) {
@@ -87,8 +89,8 @@ namespace ts {
8789
// Update changed files and copy semantic diagnostics if we can
8890
const referencedMap = state.referencedMap;
8991
const oldReferencedMap = useOldState ? oldState!.referencedMap : undefined;
90-
const copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldState!.program.getCompilerOptions().skipLibCheck;
91-
const copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldState!.program.getCompilerOptions().skipDefaultLibCheck;
92+
const copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions!.skipLibCheck;
93+
const copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions!.skipDefaultLibCheck;
9294
state.fileInfos.forEach((info, sourceFilePath) => {
9395
let oldInfo: Readonly<BuilderState.FileInfo> | undefined;
9496
let newReferences: BuilderState.ReferencedSet | undefined;
@@ -209,7 +211,7 @@ namespace ts {
209211
state.cleanedDiagnosticsOfLibFiles = true;
210212
const options = state.program.getCompilerOptions();
211213
if (forEach(state.program.getSourceFiles(), f =>
212-
!contains(state.allFilesExcludingDefaultLibraryFile, f) &&
214+
state.program.isSourceFileDefaultLibrary(f) &&
213215
!skipTypeChecking(f, options) &&
214216
removeSemanticDiagnosticsOf(state, f.path)
215217
)) {

0 commit comments

Comments
 (0)