@@ -1350,6 +1350,7 @@ namespace ts {
1350
1350
}
1351
1351
1352
1352
function getUpToDateStatusWorker ( state : SolutionBuilderState , project : ParsedCommandLine , resolvedPath : ResolvedConfigFilePath ) : UpToDateStatus {
1353
+ const force = ! ! state . options . force ;
1353
1354
let newestInputFileName : string = undefined ! ;
1354
1355
let newestInputFileTime = minimumDate ;
1355
1356
const { host } = state ;
@@ -1362,10 +1363,12 @@ namespace ts {
1362
1363
} ;
1363
1364
}
1364
1365
1365
- const inputTime = getModifiedTime ( host , inputFile ) ; host . getModifiedTime ( inputFile ) ;
1366
- if ( inputTime > newestInputFileTime ) {
1367
- newestInputFileName = inputFile ;
1368
- newestInputFileTime = inputTime ;
1366
+ if ( ! force ) {
1367
+ const inputTime = getModifiedTime ( host , inputFile ) ; host . getModifiedTime ( inputFile ) ;
1368
+ if ( inputTime > newestInputFileTime ) {
1369
+ newestInputFileName = inputFile ;
1370
+ newestInputFileTime = inputTime ;
1371
+ }
1369
1372
}
1370
1373
}
1371
1374
@@ -1387,39 +1390,41 @@ namespace ts {
1387
1390
let missingOutputFileName : string | undefined ;
1388
1391
let newestDeclarationFileContentChangedTime = minimumDate ;
1389
1392
let isOutOfDateWithInputs = false ;
1390
- for ( const output of outputs ) {
1391
- // Output is missing; can stop checking
1392
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
1393
- if ( ! host . fileExists ( output ) ) {
1394
- missingOutputFileName = output ;
1395
- break ;
1396
- }
1393
+ if ( ! force ) {
1394
+ for ( const output of outputs ) {
1395
+ // Output is missing; can stop checking
1396
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
1397
+ if ( ! host . fileExists ( output ) ) {
1398
+ missingOutputFileName = output ;
1399
+ break ;
1400
+ }
1397
1401
1398
- const outputTime = getModifiedTime ( host , output ) ;
1399
- if ( outputTime < oldestOutputFileTime ) {
1400
- oldestOutputFileTime = outputTime ;
1401
- oldestOutputFileName = output ;
1402
- }
1402
+ const outputTime = getModifiedTime ( host , output ) ;
1403
+ if ( outputTime < oldestOutputFileTime ) {
1404
+ oldestOutputFileTime = outputTime ;
1405
+ oldestOutputFileName = output ;
1406
+ }
1403
1407
1404
- // If an output is older than the newest input, we can stop checking
1405
- // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
1406
- if ( outputTime < newestInputFileTime ) {
1407
- isOutOfDateWithInputs = true ;
1408
- break ;
1409
- }
1408
+ // If an output is older than the newest input, we can stop checking
1409
+ // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
1410
+ if ( outputTime < newestInputFileTime ) {
1411
+ isOutOfDateWithInputs = true ;
1412
+ break ;
1413
+ }
1410
1414
1411
- if ( outputTime > newestOutputFileTime ) {
1412
- newestOutputFileTime = outputTime ;
1413
- newestOutputFileName = output ;
1414
- }
1415
+ if ( outputTime > newestOutputFileTime ) {
1416
+ newestOutputFileTime = outputTime ;
1417
+ newestOutputFileName = output ;
1418
+ }
1415
1419
1416
- // Keep track of when the most recent time a .d.ts file was changed.
1417
- // In addition to file timestamps, we also keep track of when a .d.ts file
1418
- // had its file touched but not had its contents changed - this allows us
1419
- // to skip a downstream typecheck
1420
- if ( isDeclarationFile ( output ) ) {
1421
- const outputModifiedTime = getModifiedTime ( host , output ) ;
1422
- newestDeclarationFileContentChangedTime = newer ( newestDeclarationFileContentChangedTime , outputModifiedTime ) ;
1420
+ // Keep track of when the most recent time a .d.ts file was changed.
1421
+ // In addition to file timestamps, we also keep track of when a .d.ts file
1422
+ // had its file touched but not had its contents changed - this allows us
1423
+ // to skip a downstream typecheck
1424
+ if ( isDeclarationFile ( output ) ) {
1425
+ const outputModifiedTime = getModifiedTime ( host , output ) ;
1426
+ newestDeclarationFileContentChangedTime = newer ( newestDeclarationFileContentChangedTime , outputModifiedTime ) ;
1427
+ }
1423
1428
}
1424
1429
}
1425
1430
@@ -1459,7 +1464,8 @@ namespace ts {
1459
1464
}
1460
1465
1461
1466
// Check oldest output file name only if there is no missing output file name
1462
- if ( ! missingOutputFileName ) {
1467
+ // (a check we will have skipped if this is a forced build)
1468
+ if ( ! force && ! missingOutputFileName ) {
1463
1469
// If the upstream project's newest file is older than our oldest output, we
1464
1470
// can't be out of date because of it
1465
1471
if ( refStatus . newestInputFileTime && refStatus . newestInputFileTime <= oldestOutputFileTime ) {
@@ -1509,7 +1515,7 @@ namespace ts {
1509
1515
if ( extendedConfigStatus ) return extendedConfigStatus ;
1510
1516
}
1511
1517
1512
- if ( ! state . buildInfoChecked . has ( resolvedPath ) ) {
1518
+ if ( ! force && ! state . buildInfoChecked . has ( resolvedPath ) ) {
1513
1519
state . buildInfoChecked . set ( resolvedPath , true ) ;
1514
1520
const buildInfoPath = getTsBuildInfoEmitOutputFilePath ( project . options ) ;
1515
1521
if ( buildInfoPath ) {
@@ -2005,6 +2011,14 @@ namespace ts {
2005
2011
}
2006
2012
2007
2013
function reportUpToDateStatus ( state : SolutionBuilderState , configFileName : string , status : UpToDateStatus ) {
2014
+ if ( state . options . force && ( status . type === UpToDateStatusType . UpToDate || status . type === UpToDateStatusType . UpToDateWithUpstreamTypes ) ) {
2015
+ return reportStatus (
2016
+ state ,
2017
+ Diagnostics . Project_0_is_being_forcibly_rebuilt ,
2018
+ relName ( state , configFileName )
2019
+ ) ;
2020
+ }
2021
+
2008
2022
switch ( status . type ) {
2009
2023
case UpToDateStatusType . OutOfDateWithSelf :
2010
2024
return reportStatus (
0 commit comments