Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state (#37302)

* Make the systems for baselining default to pretty

* Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state
This happens in build scenarios since semantic diagnostics are queried before emit and hence files are added to seenAffectedFiles pending emit
Fixes #37269
This commit is contained in:
Sheetal Nandi
2020-03-12 10:54:30 -07:00
committed by GitHub
parent 41a80f5d92
commit 1f710167de
347 changed files with 3157 additions and 2065 deletions

View File

@@ -201,6 +201,7 @@ namespace ts {
state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit.slice();
state.affectedFilesPendingEmitKind = cloneMapOrUndefined(oldState!.affectedFilesPendingEmitKind);
state.affectedFilesPendingEmitIndex = oldState!.affectedFilesPendingEmitIndex;
state.seenAffectedFiles = createMap();
}
}
@@ -247,8 +248,8 @@ namespace ts {
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
// Add all files to affectedFilesPendingEmit since emit changed
newProgram.getSourceFiles().forEach(f => addToAffectedFilesPendingEmit(state, f.resolvedPath, BuilderFileEmit.Full));
Debug.assert(state.seenAffectedFiles === undefined);
state.seenAffectedFiles = createMap<true>();
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
state.seenAffectedFiles = state.seenAffectedFiles || createMap<true>();
}
state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;

View File

@@ -32,6 +32,11 @@ namespace fakes {
this._env = env;
}
// Pretty output
writeOutputIsTTY() {
return true;
}
public write(message: string) {
this.output.push(message);
}

View File

@@ -445,6 +445,11 @@ interface Array<T> { length: number; [n: number]: T; }`
this.reloadFS(fileOrFolderorSymLinkList);
}
// Output is pretty
writeOutputIsTTY() {
return true;
}
getNewLine() {
return this.newLine;
}

View File

@@ -1131,6 +1131,38 @@ export function someFn() { }`);
}
],
});
verifyTscWatch({
scenario,
subScenario: "works when noUnusedParameters changes to false",
commandLineArgs: ["-b", "-w"],
sys: () => {
const index: File = {
path: `${projectRoot}/index.ts`,
content: `const fn = (a: string, b: string) => b;`
};
const configFile: File = {
path: `${projectRoot}/tsconfig.json`,
content: JSON.stringify({
compilerOptions: {
noUnusedParameters: true
}
})
};
return createWatchedSystem([index, configFile, libFile], { currentDirectory: projectRoot });
},
changes: [
sys => {
sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({
compilerOptions: {
noUnusedParameters: false
}
}));
sys.runQueuedTimeoutCallbacks();
return "Change tsconfig to set noUnusedParameters to false";
},
]
});
});
describe("unittests:: tsbuild:: watchMode:: with demo project", () => {