Skip to content

Commit 7785a87

Browse files
committed
Cleanup
1 parent 82fb56b commit 7785a87

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/compiler/builder.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace ts {
2828
/**
2929
* The map has key by source file's path that has been changed
3030
*/
31-
changedFilesSet: Set<Path>;
31+
changedFilesSet?: Set<Path>;
3232
/**
3333
* Set of affected files being iterated
3434
*/
@@ -102,6 +102,10 @@ namespace ts {
102102
* Cache of bind and check diagnostics for files with their Path being the key
103103
*/
104104
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>;
105109
/**
106110
* Current index to retrieve affected file from
107111
*/
@@ -168,9 +172,8 @@ namespace ts {
168172
!compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions!);
169173
const canCopyEmitSignatures = compilerOptions.composite &&
170174
oldState?.emitSignatures &&
171-
oldCompilerOptions &&
172175
!outFilePath &&
173-
!compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
176+
!compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions!);
174177
if (useOldState) {
175178
// Verify the sanity of old state
176179
if (!oldState!.currentChangedFilePath) {
@@ -179,11 +182,11 @@ namespace ts {
179182
}
180183
const changedFilesSet = oldState!.changedFilesSet;
181184
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");
183186
}
184187

185188
// Copy old state's changed files set
186-
changedFilesSet.forEach(value => state.changedFilesSet.add(value));
189+
changedFilesSet?.forEach(value => state.changedFilesSet.add(value));
187190
if (!outFilePath && oldState!.affectedFilesPendingEmit) {
188191
state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit.slice();
189192
state.affectedFilesPendingEmitKind = oldState!.affectedFilesPendingEmitKind && new Map(oldState!.affectedFilesPendingEmitKind);
@@ -249,7 +252,8 @@ namespace ts {
249252
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
250253
state.seenAffectedFiles = state.seenAffectedFiles || new Set();
251254
}
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);
253257
return state;
254258
}
255259

src/testRunner/unittests/tscWatch/incremental.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace ts.tscWatch {
155155
});
156156

157157
const state = builderProgram.getState();
158-
assert.equal(state.changedFilesSet.size, 0, "changes");
158+
assert.equal(state.changedFilesSet!.size, 0, "changes");
159159

160160
assert.equal(state.fileInfos.size, 3, "FileInfo size");
161161
assert.deepEqual(state.fileInfos.get(libFile.path as Path), {

0 commit comments

Comments
 (0)