Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple output .d.ts files changedness correctly #25370

Merged
merged 2 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ namespace ts {
*/
export interface UpToDate {
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
newestInputFileTime: Date;
newestInputFileName: string;
newestDeclarationFileContentChangedTime: Date;
newestOutputFileTime: Date;
newestOutputFileName: string;
oldestOutputFileName: string;
newestInputFileTime?: Date;
newestInputFileName?: string;
newestDeclarationFileContentChangedTime?: Date;
newestOutputFileTime?: Date;
newestOutputFileName?: string;
oldestOutputFileName?: string;
}

/**
Expand Down Expand Up @@ -801,15 +801,19 @@ namespace ts {
}

let newestDeclarationFileContentChangedTime = minimumDate;
let anyDtsChanged = false;
program.emit(/*targetSourceFile*/ undefined, (fileName, content, writeBom, onError) => {
let priorChangeTime: Date | undefined;

if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) {
if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) {
if (compilerHost.readFile(fileName) === content) {
// Check for unchanged .d.ts files
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName);
}
else {
anyDtsChanged = true;
}
}

compilerHost.writeFile(fileName, content, writeBom, onError, emptyArray);
Expand All @@ -819,7 +823,11 @@ namespace ts {
}
});

context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime } as UpToDateStatus);
const status: UpToDateStatus = {
type: UpToDateStatusType.UpToDate,
newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime
};
context.projectStatus.setValue(proj, status);
return resultFlags;
}

Expand Down Expand Up @@ -1134,13 +1142,13 @@ namespace ts {

// If the upstream project's newest file is older than our oldest output, we
// can't be out of date because of it
if (refStatus.newestInputFileTime <= oldestOutputFileTime) {
if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
continue;
}

// If the upstream project has only change .d.ts files, and we've built
// *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
pseudoUpToDate = true;
upstreamChangedProject = ref.path;
continue;
Expand Down Expand Up @@ -1224,8 +1232,8 @@ namespace ts {
if (status.newestInputFileTime !== undefined) {
return formatMessage(Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
relName(configFileName),
relName(status.newestInputFileName),
relName(status.oldestOutputFileName));
relName(status.newestInputFileName || ""),
relName(status.oldestOutputFileName || ""));
}
// Don't report anything for "up to date because it was already built" -- too verbose
break;
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9528,12 +9528,12 @@ declare namespace ts {
*/
interface UpToDate {
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
newestInputFileTime: Date;
newestInputFileName: string;
newestDeclarationFileContentChangedTime: Date;
newestOutputFileTime: Date;
newestOutputFileName: string;
oldestOutputFileName: string;
newestInputFileTime?: Date;
newestInputFileName?: string;
newestDeclarationFileContentChangedTime?: Date;
newestOutputFileTime?: Date;
newestOutputFileName?: string;
oldestOutputFileName?: string;
}
/**
* One or more of the outputs of the project does not exist.
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4476,12 +4476,12 @@ declare namespace ts {
*/
interface UpToDate {
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
newestInputFileTime: Date;
newestInputFileName: string;
newestDeclarationFileContentChangedTime: Date;
newestOutputFileTime: Date;
newestOutputFileName: string;
oldestOutputFileName: string;
newestInputFileTime?: Date;
newestInputFileName?: string;
newestDeclarationFileContentChangedTime?: Date;
newestOutputFileTime?: Date;
newestOutputFileName?: string;
oldestOutputFileName?: string;
}
/**
* One or more of the outputs of the project does not exist.
Expand Down
1 change: 1 addition & 0 deletions tests/projects/sample1/core/anotherModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const World = "hello";