mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
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:
@@ -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;
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace fakes {
|
||||
this._env = env;
|
||||
}
|
||||
|
||||
// Pretty output
|
||||
writeOutputIsTTY() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public write(message: string) {
|
||||
this.output.push(message);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user