Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fd9e602

Browse files
authoredMar 25, 2020
When the global file is deleted mark all files as changed (microsoft#37538)
* Add test case when the errors are not refreshed if global file is deleted Testcase for microsoft#36728 * When the global file is deleted mark all files as changed Fixes microsoft#36728 * Update other baselines to fix file info
1 parent 6bd68a8 commit fd9e602

File tree

107 files changed

+1963
-797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1963
-797
lines changed
 

‎src/compiler/builder.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ namespace ts {
245245
}
246246
});
247247

248-
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
248+
// If the global file is removed, add all files as changed
249+
if (useOldState && forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath))) {
250+
BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined)
251+
.forEach(file => state.changedFilesSet.set(file.resolvedPath, true));
252+
}
253+
else if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
249254
// Add all files to affectedFilesPendingEmit since emit changed
250255
newProgram.getSourceFiles().forEach(f => addToAffectedFilesPendingEmit(state, f.resolvedPath, BuilderFileEmit.Full));
251256
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
@@ -701,7 +706,7 @@ namespace ts {
701706
const fileInfos: MapLike<BuilderState.FileInfo> = {};
702707
state.fileInfos.forEach((value, key) => {
703708
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
704-
fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature };
709+
fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope };
705710
});
706711

707712
const result: ProgramBuildInfo = {

‎src/compiler/builderState.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace ts {
6868
export interface FileInfo {
6969
readonly version: string;
7070
signature: string | undefined;
71+
affectsGlobalScope: boolean;
7172
}
7273
/**
7374
* Referenced files with values for the keys as referenced file's path to be true
@@ -225,7 +226,7 @@ namespace ts {
225226
}
226227
}
227228
}
228-
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature });
229+
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
229230
}
230231

231232
return {
@@ -488,14 +489,14 @@ namespace ts {
488489
/**
489490
* Gets all files of the program excluding the default library file
490491
*/
491-
function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile): readonly SourceFile[] {
492+
export function getAllFilesExcludingDefaultLibraryFile(state: BuilderState, programOfThisState: Program, firstSourceFile: SourceFile | undefined): readonly SourceFile[] {
492493
// Use cached result
493494
if (state.allFilesExcludingDefaultLibraryFile) {
494495
return state.allFilesExcludingDefaultLibraryFile;
495496
}
496497

497498
let result: SourceFile[] | undefined;
498-
addSourceFile(firstSourceFile);
499+
if (firstSourceFile) addSourceFile(firstSourceFile);
499500
for (const sourceFile of programOfThisState.getSourceFiles()) {
500501
if (sourceFile !== firstSourceFile) {
501502
addSourceFile(sourceFile);

0 commit comments

Comments
 (0)
Please sign in to comment.