@@ -41,7 +41,7 @@ namespace ts {
41
41
/**
42
42
* True if the semantic diagnostics were copied from the old state
43
43
*/
44
- semanticDiagnosticsFromOldStateFiles ?: number ;
44
+ semanticDiagnosticsFromOldState ?: Map < true > ;
45
45
/**
46
46
* program corresponding to this state
47
47
*/
@@ -104,7 +104,10 @@ namespace ts {
104
104
const diagnostics = oldState ! . semanticDiagnosticsPerFile ! . get ( sourceFilePath ) ;
105
105
if ( diagnostics ) {
106
106
state . semanticDiagnosticsPerFile ! . set ( sourceFilePath , diagnostics ) ;
107
- state . semanticDiagnosticsFromOldStateFiles = ( state . semanticDiagnosticsFromOldStateFiles || 0 ) + 1 ;
107
+ if ( ! state . semanticDiagnosticsFromOldState ) {
108
+ state . semanticDiagnosticsFromOldState = createMap < true > ( ) ;
109
+ }
110
+ state . semanticDiagnosticsFromOldState . set ( sourceFilePath , true ) ;
108
111
}
109
112
}
110
113
} ) ;
@@ -184,13 +187,8 @@ namespace ts {
184
187
* Remove the semantic diagnostics cached from old state for affected File and the files that are referencing modules that export entities from affected file
185
188
*/
186
189
function cleanSemanticDiagnosticsOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile ) {
187
- if ( ! state . semanticDiagnosticsFromOldStateFiles ) {
188
- Debug . assert ( ! state . semanticDiagnosticsPerFile ! . has ( affectedFile . path ) ) ;
189
- return ;
190
- }
191
-
192
190
if ( removeSemanticDiagnosticsOf ( state , affectedFile . path ) ) {
193
- // If there are no more diagnostics from old cache, remove them
191
+ // If there are no more diagnostics from old cache, done
194
192
return ;
195
193
}
196
194
@@ -235,12 +233,12 @@ namespace ts {
235
233
* returns true if there are no more semantic diagnostics from the old state
236
234
*/
237
235
function removeSemanticDiagnosticsOf ( state : BuilderProgramState , path : Path ) {
238
- if ( state . semanticDiagnosticsPerFile ! . delete ( path ) ) {
239
- Debug . assert ( ( state . semanticDiagnosticsFromOldStateFiles || 0 ) > 0 ) ;
240
- state . semanticDiagnosticsFromOldStateFiles ! -- ;
241
- return ! state . semanticDiagnosticsFromOldStateFiles ;
236
+ if ( ! state . semanticDiagnosticsFromOldState ) {
237
+ return false ;
242
238
}
243
- return false ;
239
+ state . semanticDiagnosticsFromOldState . delete ( path ) ;
240
+ state . semanticDiagnosticsPerFile ! . delete ( path ) ;
241
+ return ! state . semanticDiagnosticsFromOldState . size ;
244
242
}
245
243
246
244
/**
0 commit comments