@@ -1469,39 +1469,18 @@ namespace ts {
1469
1469
if ( ! force ) ( referenceStatuses ||= [ ] ) . push ( { ref, refStatus } ) ;
1470
1470
}
1471
1471
}
1472
-
1473
- // Check output files
1474
- let newestInputFileName : string = undefined ! ;
1475
- let newestInputFileTime = minimumDate ;
1476
- const { host } = state ;
1477
- // Get timestamps of input files
1478
- for ( const inputFile of project . fileNames ) {
1479
- const inputTime = getModifiedTime ( state , inputFile ) ;
1480
- if ( inputTime === missingFileModifiedTime ) {
1481
- return {
1482
- type : UpToDateStatusType . Unbuildable ,
1483
- reason : `${ inputFile } does not exist`
1484
- } ;
1485
- }
1486
-
1487
- if ( ! force ) {
1488
- if ( inputTime > newestInputFileTime ) {
1489
- newestInputFileName = inputFile ;
1490
- newestInputFileTime = inputTime ;
1491
- }
1492
- }
1493
- }
1494
-
1495
1472
if ( force ) return { type : UpToDateStatusType . ForceBuild } ;
1496
1473
1474
+ // Check buildinfo first
1475
+ const { host } = state ;
1497
1476
const buildInfoPath = getTsBuildInfoEmitOutputFilePath ( project . options ) ;
1498
- // Now see if all outputs are newer than the newest input
1499
1477
let oldestOutputFileName = "(none)" ;
1500
1478
let oldestOutputFileTime = maximumDate ;
1501
1479
let newestDeclarationFileContentChangedTime ;
1480
+ let buildInfoTime : Date | undefined ;
1502
1481
if ( buildInfoPath ) {
1503
- const outputTime = ts . getModifiedTime ( host , buildInfoPath ) ;
1504
- if ( outputTime === missingFileModifiedTime ) {
1482
+ buildInfoTime = ts . getModifiedTime ( host , buildInfoPath ) ;
1483
+ if ( buildInfoTime === missingFileModifiedTime ) {
1505
1484
return {
1506
1485
type : UpToDateStatusType . OutputMissing ,
1507
1486
missingOutputFileName : buildInfoPath
@@ -1519,15 +1498,6 @@ namespace ts {
1519
1498
}
1520
1499
}
1521
1500
1522
- // If an output is older than the newest input, we can stop checking
1523
- if ( outputTime < newestInputFileTime ) {
1524
- return {
1525
- type : UpToDateStatusType . OutOfDateWithSelf ,
1526
- outOfDateOutputFileName : buildInfoPath ,
1527
- newerInputFileName : newestInputFileName
1528
- } ;
1529
- }
1530
-
1531
1501
if ( buildInfo . program ) {
1532
1502
if ( buildInfo . program . changeFileSet ?. length ||
1533
1503
( ! buildInfo . program . options ?. noEmit && buildInfo . program . affectedFilesPendingEmit ?. length ) ) {
@@ -1538,15 +1508,44 @@ namespace ts {
1538
1508
}
1539
1509
}
1540
1510
1541
- oldestOutputFileTime = outputTime ;
1511
+ oldestOutputFileTime = buildInfoTime ;
1542
1512
oldestOutputFileName = buildInfoPath ;
1543
1513
}
1514
+
1515
+ // Check input files
1516
+ let newestInputFileName : string = undefined ! ;
1517
+ let newestInputFileTime = minimumDate ;
1518
+ // Get timestamps of input files
1519
+ for ( const inputFile of project . fileNames ) {
1520
+ const inputTime = getModifiedTime ( state , inputFile ) ;
1521
+ if ( inputTime === missingFileModifiedTime ) {
1522
+ return {
1523
+ type : UpToDateStatusType . Unbuildable ,
1524
+ reason : `${ inputFile } does not exist`
1525
+ } ;
1526
+ }
1527
+
1528
+ // If an buildInfo is older than the newest input, we can stop checking
1529
+ if ( buildInfoTime && buildInfoTime < inputTime ) {
1530
+ return {
1531
+ type : UpToDateStatusType . OutOfDateWithSelf ,
1532
+ outOfDateOutputFileName : buildInfoPath ! ,
1533
+ newerInputFileName : inputFile
1534
+ } ;
1535
+ }
1536
+
1537
+ if ( inputTime > newestInputFileTime ) {
1538
+ newestInputFileName = inputFile ;
1539
+ newestInputFileTime = inputTime ;
1540
+ }
1541
+ }
1542
+
1543
+ // Now see if all outputs are newer than the newest input
1544
1544
// Dont check output timestamps if we have buildinfo telling us output is uptodate
1545
- else {
1545
+ if ( ! buildInfoPath ) {
1546
1546
// Collect the expected outputs of this project
1547
1547
const outputs = getAllProjectOutputs ( project , ! host . useCaseSensitiveFileNames ( ) ) ;
1548
1548
for ( const output of outputs ) {
1549
- if ( buildInfoPath === output ) continue ;
1550
1549
// Output is missing; can stop checking
1551
1550
const outputTime = ts . getModifiedTime ( state . host , output ) ;
1552
1551
if ( outputTime === missingFileModifiedTime ) {
0 commit comments