Skip to content

Commit c1c4a39

Browse files
Merge pull request microsoft#25370 from RyanCavanaugh/fix25337
Handle multiple output .d.ts files changedness correctly
2 parents 8181405 + 3031f7b commit c1c4a39

4 files changed

Lines changed: 33 additions & 24 deletions

File tree

src/compiler/tsbuild.ts

Lines changed: 20 additions & 12 deletions
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;

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9527,12 +9527,12 @@ declare namespace ts {
95279527
*/
95289528
interface UpToDate {
95299529
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
9530-
newestInputFileTime: Date;
9531-
newestInputFileName: string;
9532-
newestDeclarationFileContentChangedTime: Date;
9533-
newestOutputFileTime: Date;
9534-
newestOutputFileName: string;
9535-
oldestOutputFileName: string;
9530+
newestInputFileTime?: Date;
9531+
newestInputFileName?: string;
9532+
newestDeclarationFileContentChangedTime?: Date;
9533+
newestOutputFileTime?: Date;
9534+
newestOutputFileName?: string;
9535+
oldestOutputFileName?: string;
95369536
}
95379537
/**
95389538
* One or more of the outputs of the project does not exist.

tests/baselines/reference/api/typescript.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,12 +4473,12 @@ declare namespace ts {
44734473
*/
44744474
interface UpToDate {
44754475
type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes;
4476-
newestInputFileTime: Date;
4477-
newestInputFileName: string;
4478-
newestDeclarationFileContentChangedTime: Date;
4479-
newestOutputFileTime: Date;
4480-
newestOutputFileName: string;
4481-
oldestOutputFileName: string;
4476+
newestInputFileTime?: Date;
4477+
newestInputFileName?: string;
4478+
newestDeclarationFileContentChangedTime?: Date;
4479+
newestOutputFileTime?: Date;
4480+
newestOutputFileName?: string;
4481+
oldestOutputFileName?: string;
44824482
}
44834483
/**
44844484
* One or more of the outputs of the project does not exist.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const World = "hello";

0 commit comments

Comments
 (0)