Skip to content

Commit 69bf73f

Browse files
committed
Handle multiple output .d.ts files changedness correctly
Fixes microsoft#25337
1 parent 38d6491 commit 69bf73f

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/compiler/tsbuild.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ namespace ts {
126126
*/
127127
export interface UpToDate {
128128
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
129-
newestInputFileTime: Date;
130-
newestInputFileName: string;
131-
newestDeclarationFileContentChangedTime: Date;
132-
newestOutputFileTime: Date;
133-
newestOutputFileName: string;
134-
oldestOutputFileName: string;
129+
newestInputFileTime?: Date;
130+
newestInputFileName?: string;
131+
newestDeclarationFileContentChangedTime?: Date;
132+
newestOutputFileTime?: Date;
133+
newestOutputFileName?: string;
134+
oldestOutputFileName?: string;
135135
}
136136

137137
/**
@@ -801,15 +801,19 @@ namespace ts {
801801
}
802802

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

807-
if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) {
808+
if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) {
808809
if (compilerHost.readFile(fileName) === content) {
809810
// Check for unchanged .d.ts files
810811
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
811812
priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName);
812813
}
814+
else {
815+
anyDtsChanged = true;
816+
}
813817
}
814818

815819
compilerHost.writeFile(fileName, content, writeBom, onError, emptyArray);
@@ -819,7 +823,11 @@ namespace ts {
819823
}
820824
});
821825

822-
context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime } as UpToDateStatus);
826+
const status: UpToDateStatus = {
827+
type: UpToDateStatusType.UpToDate,
828+
newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime
829+
};
830+
context.projectStatus.setValue(proj, status);
823831
return resultFlags;
824832
}
825833

@@ -1134,13 +1142,13 @@ namespace ts {
11341142

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

11411149
// If the upstream project has only change .d.ts files, and we've built
11421150
// *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
1143-
if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
1151+
if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
11441152
pseudoUpToDate = true;
11451153
upstreamChangedProject = ref.path;
11461154
continue;
@@ -1224,8 +1232,8 @@ namespace ts {
12241232
if (status.newestInputFileTime !== undefined) {
12251233
return formatMessage(Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
12261234
relName(configFileName),
1227-
relName(status.newestInputFileName),
1228-
relName(status.oldestOutputFileName));
1235+
relName(status.newestInputFileName || ""),
1236+
relName(status.oldestOutputFileName || ""));
12291237
}
12301238
// Don't report anything for "up to date because it was already built" -- too verbose
12311239
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const World = "hello";

0 commit comments

Comments
 (0)