@@ -28,7 +28,7 @@ namespace ts {
28
28
/**
29
29
* The map has key by source file's path that has been changed
30
30
*/
31
- changedFilesSet : Set < Path > ;
31
+ changedFilesSet ? : Set < Path > ;
32
32
/**
33
33
* Set of affected files being iterated
34
34
*/
@@ -102,6 +102,10 @@ namespace ts {
102
102
* Cache of bind and check diagnostics for files with their Path being the key
103
103
*/
104
104
semanticDiagnosticsPerFile : ESMap < Path , readonly Diagnostic [ ] > | undefined ;
105
+ /**
106
+ * The map has key by source file's path that has been changed
107
+ */
108
+ changedFilesSet : Set < Path > ;
105
109
/**
106
110
* Current index to retrieve affected file from
107
111
*/
@@ -168,9 +172,8 @@ namespace ts {
168
172
! compilerOptionsAffectSemanticDiagnostics ( compilerOptions , oldCompilerOptions ! ) ;
169
173
const canCopyEmitSignatures = compilerOptions . composite &&
170
174
oldState ?. emitSignatures &&
171
- oldCompilerOptions &&
172
175
! outFilePath &&
173
- ! compilerOptionsAffectDeclarationPath ( compilerOptions , oldCompilerOptions ) ;
176
+ ! compilerOptionsAffectDeclarationPath ( compilerOptions , oldCompilerOptions ! ) ;
174
177
if ( useOldState ) {
175
178
// Verify the sanity of old state
176
179
if ( ! oldState ! . currentChangedFilePath ) {
@@ -179,11 +182,11 @@ namespace ts {
179
182
}
180
183
const changedFilesSet = oldState ! . changedFilesSet ;
181
184
if ( canCopySemanticDiagnostics ) {
182
- Debug . assert ( ! changedFilesSet . size || ! forEachKey ( changedFilesSet , path => oldState ! . semanticDiagnosticsPerFile ! . has ( path ) ) , "Semantic diagnostics shouldnt be available for changed files" ) ;
185
+ Debug . assert ( ! changedFilesSet ? .size || ! forEachKey ( changedFilesSet , path => oldState ! . semanticDiagnosticsPerFile ! . has ( path ) ) , "Semantic diagnostics shouldnt be available for changed files" ) ;
183
186
}
184
187
185
188
// Copy old state's changed files set
186
- changedFilesSet . forEach ( value => state . changedFilesSet . add ( value ) ) ;
189
+ changedFilesSet ? .forEach ( value => state . changedFilesSet . add ( value ) ) ;
187
190
if ( ! outFilePath && oldState ! . affectedFilesPendingEmit ) {
188
191
state . affectedFilesPendingEmit = oldState ! . affectedFilesPendingEmit . slice ( ) ;
189
192
state . affectedFilesPendingEmitKind = oldState ! . affectedFilesPendingEmitKind && new Map ( oldState ! . affectedFilesPendingEmitKind ) ;
@@ -249,7 +252,8 @@ namespace ts {
249
252
Debug . assert ( ! state . seenAffectedFiles || ! state . seenAffectedFiles . size ) ;
250
253
state . seenAffectedFiles = state . seenAffectedFiles || new Set ( ) ;
251
254
}
252
- state . buildInfoEmitPending = ! useOldState || state . changedFilesSet . size !== oldState ! . changedFilesSet . size ;
255
+ // Since old states change files set is copied, any additional change means we would need to emit build info
256
+ state . buildInfoEmitPending = ! useOldState || state . changedFilesSet . size !== ( oldState ! . changedFilesSet ?. size || 0 ) ;
253
257
return state ;
254
258
}
255
259
0 commit comments