Skip to content

Commit

Permalink
Merge pull request microsoft#27688 from Microsoft/fixTsBuildIncrement…
Browse files Browse the repository at this point in the history
…alNoErrorScenario

Remove any existing errors in case of successful build in tsbuild watch mode
  • Loading branch information
sheetalkamat authored Oct 10, 2018
2 parents dd764b3 + ba0f558 commit 3e91652
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,9 @@ namespace ts {
type: UpToDateStatusType.UpToDate,
newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime
};
if (options.watch) {
diagnostics.removeKey(proj);
}
projectStatus.setValue(proj, status);
return resultFlags;

Expand Down
52 changes: 52 additions & 0 deletions src/testRunner/unittests/tsbuildWatchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,58 @@ function myFunc() { return 100; }`);
}
});

it("when referenced project change introduces error in the down stream project and then fixes it", () => {
const subProjectLibrary = `${projectsLocation}/${project}/Library`;
const libraryTs: File = {
path: `${subProjectLibrary}/library.ts`,
content: `
interface SomeObject
{
message: string;
}
export function createSomeObject(): SomeObject
{
return {
message: "new Object"
};
}`
};
const libraryTsconfig: File = {
path: `${subProjectLibrary}/tsconfig.json`,
content: JSON.stringify({ compilerOptions: { composite: true } })
};
const subProjectApp = `${projectsLocation}/${project}/App`;
const appTs: File = {
path: `${subProjectApp}/app.ts`,
content: `import { createSomeObject } from "../Library/library";
createSomeObject().message;`
};
const appTsconfig: File = {
path: `${subProjectApp}/tsconfig.json`,
content: JSON.stringify({ references: [{ path: "../Library" }] })
};

const files = [libFile, libraryTs, libraryTsconfig, appTs, appTsconfig];
const host = createWatchedSystem(files, { currentDirectory: `${projectsLocation}/${project}` });
createSolutionBuilderWithWatch(host, ["App"]);
checkOutputErrorsInitial(host, emptyArray);

// Change message in library to message2
host.writeFile(libraryTs.path, libraryTs.content.replace(/message/g, "message2"));
host.checkTimeoutQueueLengthAndRun(1); // Build library
host.checkTimeoutQueueLengthAndRun(1); // Build App
checkOutputErrorsIncremental(host, [
"App/app.ts(2,20): error TS2551: Property 'message' does not exist on type 'SomeObject'. Did you mean 'message2'?\n"
]);

// Revert library changes
host.writeFile(libraryTs.path, libraryTs.content);
host.checkTimeoutQueueLengthAndRun(1); // Build library
host.checkTimeoutQueueLengthAndRun(1); // Build App
checkOutputErrorsIncremental(host, emptyArray);
});

describe("reports errors in all projects on incremental compile", () => {
function verifyIncrementalErrors(defaultBuildOptions?: BuildOptions, disabledConsoleClear?: boolean) {
const host = createSolutionInWatchMode(allFiles, defaultBuildOptions, disabledConsoleClear);
Expand Down

0 comments on commit 3e91652

Please sign in to comment.