@@ -39,7 +39,7 @@ namespace ts {
39
39
*/
40
40
seenAffectedFiles : Map < true > | undefined ;
41
41
/**
42
- * program corresponding to this state
42
+ * whether this program has cleaned semantic diagnostics cache for lib files
43
43
*/
44
44
cleanedDiagnosticsOfLibFiles ?: boolean ;
45
45
/**
@@ -68,9 +68,11 @@ namespace ts {
68
68
state . semanticDiagnosticsPerFile = createMap < ReadonlyArray < Diagnostic > > ( ) ;
69
69
}
70
70
state . changedFilesSet = createMap < true > ( ) ;
71
+
71
72
const useOldState = BuilderState . canReuseOldState ( state . referencedMap , oldState ) ;
73
+ const oldCompilerOptions = useOldState ? oldState ! . program . getCompilerOptions ( ) : undefined ;
72
74
const canCopySemanticDiagnostics = useOldState && oldState ! . semanticDiagnosticsPerFile && ! ! state . semanticDiagnosticsPerFile &&
73
- ! compilerOptionsAffectSemanticDiagnostics ( compilerOptions , oldState ! . program . getCompilerOptions ( ) ) ;
75
+ ! compilerOptionsAffectSemanticDiagnostics ( compilerOptions , oldCompilerOptions ! ) ;
74
76
if ( useOldState ) {
75
77
// Verify the sanity of old state
76
78
if ( ! oldState ! . currentChangedFilePath ) {
@@ -87,8 +89,8 @@ namespace ts {
87
89
// Update changed files and copy semantic diagnostics if we can
88
90
const referencedMap = state . referencedMap ;
89
91
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 ;
92
94
state . fileInfos . forEach ( ( info , sourceFilePath ) => {
93
95
let oldInfo : Readonly < BuilderState . FileInfo > | undefined ;
94
96
let newReferences : BuilderState . ReferencedSet | undefined ;
@@ -209,7 +211,7 @@ namespace ts {
209
211
state . cleanedDiagnosticsOfLibFiles = true ;
210
212
const options = state . program . getCompilerOptions ( ) ;
211
213
if ( forEach ( state . program . getSourceFiles ( ) , f =>
212
- ! contains ( state . allFilesExcludingDefaultLibraryFile , f ) &&
214
+ state . program . isSourceFileDefaultLibrary ( f ) &&
213
215
! skipTypeChecking ( f , options ) &&
214
216
removeSemanticDiagnosticsOf ( state , f . path )
215
217
) ) {
0 commit comments