Skip to content

Commit 63b3ae4

Browse files
committed
Sort affectedFilesPendingEmit for consistent build info text
1 parent bafc3b7 commit 63b3ae4

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/compiler/builder.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,10 @@ namespace ts {
757757
if (state.affectedFilesPendingEmit) {
758758
const affectedFilesPendingEmit: ProgramBuilderInfoFilePendingEmit[] = [];
759759
const seenFiles = createMap<true>();
760-
for (let i = state.affectedFilesPendingEmitIndex!; i < state.affectedFilesPendingEmit.length; i++) {
761-
const path = state.affectedFilesPendingEmit[i];
762-
if (!addToSeen(seenFiles, path)) continue;
763-
affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind!.get(path)!]);
760+
for (const path of state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(compareStringsCaseSensitive)) {
761+
if (addToSeen(seenFiles, path)) {
762+
affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind!.get(path)!]);
763+
}
764764
}
765765
result.affectedFilesPendingEmit = affectedFilesPendingEmit;
766766
}

src/testRunner/unittests/tsbuild/helpers.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,12 @@ interface Symbol {
302302
// Verify that incrementally pending affected file emit are in clean build since clean build can contain more files compared to incremental depending of noEmitOnError option
303303
if (actualAffectedFilesPendingEmit) {
304304
assert.isDefined(expectedAffectedFilesPendingEmit, `Incremental build contains affectedFilesPendingEmit, clean build should also have it: ${outputFile}::\nIncremental buildInfoText:: ${actualText}\nClean buildInfoText:: ${expectedText}`);
305-
for (const actual of actualAffectedFilesPendingEmit) {
306-
assert.isTrue(contains(expectedAffectedFilesPendingEmit, actual, ([file1], [file2]) => file1 === file2), `Incremental build contains ${actual[0]} file as pending emit, clean build should also have it: ${outputFile}::\nIncremental buildInfoText:: ${actualText}\nClean buildInfoText:: ${expectedText}`);
307-
}
305+
let expectedIndex = 0;
306+
actualAffectedFilesPendingEmit.forEach(([actualFile]) => {
307+
expectedIndex = findIndex(expectedAffectedFilesPendingEmit!, ([expectedFile]) => actualFile === expectedFile, expectedIndex);
308+
assert.notEqual(expectedIndex, -1, `Incremental build contains ${actualFile} file as pending emit, clean build should also have it: ${outputFile}::\nIncremental buildInfoText:: ${actualText}\nClean buildInfoText:: ${expectedText}`);
309+
expectedIndex++;
310+
});
308311
}
309312
}
310313
}

tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,16 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped
347347
],
348348
"affectedFilesPendingEmit": [
349349
[
350-
"../lazyindex.ts",
351-
0
350+
"../bar.ts",
351+
1
352352
],
353353
[
354354
"../index.ts",
355355
0
356356
],
357357
[
358-
"../bar.ts",
359-
1
358+
"../lazyindex.ts",
359+
0
360360
]
361361
]
362362
},

tests/baselines/reference/tsbuild/sample1/initial-build/does-not-build-downstream-projects-if-upstream-projects-have-errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ exports.multiply = multiply;
260260
],
261261
"affectedFilesPendingEmit": [
262262
[
263-
"../core/index.d.ts",
263+
"../core/anothermodule.d.ts",
264264
1
265265
],
266266
[
267-
"../core/anothermodule.d.ts",
267+
"../core/index.d.ts",
268268
1
269269
],
270270
[

0 commit comments

Comments
 (0)