@@ -455,7 +455,7 @@ namespace ts {
455
455
}
456
456
457
457
// If project references dont match
458
- if ( ! arrayIsEqualTo ( program . getProjectReferences ( ) , projectReferences ) ) {
458
+ if ( ! arrayIsEqualTo ( program . getProjectReferences ( ) , projectReferences , projectReferenceUptoDate ) ) {
459
459
return false ;
460
460
}
461
461
@@ -483,9 +483,27 @@ namespace ts {
483
483
484
484
return true ;
485
485
486
- function sourceFileNotUptoDate ( sourceFile : SourceFile ) : boolean {
487
- return sourceFile . version !== getSourceVersion ( sourceFile . path ) ||
488
- hasInvalidatedResolution ( sourceFile . path ) ;
486
+ function sourceFileNotUptoDate ( sourceFile : SourceFile ) {
487
+ return ! sourceFileVersionUptoDate ( sourceFile ) ||
488
+ hasInvalidatedResolution ( sourceFile . resolvedPath || sourceFile . path ) ;
489
+ }
490
+
491
+ function sourceFileVersionUptoDate ( sourceFile : SourceFile ) {
492
+ return sourceFile . version === getSourceVersion ( sourceFile . resolvedPath || sourceFile . path ) ;
493
+ }
494
+
495
+ function projectReferenceUptoDate ( oldRef : ProjectReference , newRef : ProjectReference , index : number ) {
496
+ if ( ! projectReferenceIsEqualTo ( oldRef , newRef ) ) {
497
+ return false ;
498
+ }
499
+ const oldResolvedRef = program ! . getResolvedProjectReferences ( ) ! [ index ] ;
500
+ if ( oldResolvedRef ) {
501
+ // If sourceFile for the oldResolvedRef existed, check the version for uptodate
502
+ return sourceFileVersionUptoDate ( oldResolvedRef . sourceFile ) ;
503
+ }
504
+ // In old program, not able to resolve project reference path,
505
+ // so if config file doesnt exist, it is uptodate.
506
+ return ! fileExists ( resolveProjectReferencePath ( oldRef ) ) ;
489
507
}
490
508
}
491
509
@@ -658,8 +676,9 @@ namespace ts {
658
676
const parsedRef = parseProjectReferenceConfigFile ( ref ) ;
659
677
resolvedProjectReferences ! . push ( parsedRef ) ;
660
678
if ( parsedRef ) {
661
- if ( parsedRef . commandLine . options . outFile ) {
662
- const dtsOutfile = changeExtension ( parsedRef . commandLine . options . outFile , ".d.ts" ) ;
679
+ const out = parsedRef . commandLine . options . outFile || parsedRef . commandLine . options . out ;
680
+ if ( out ) {
681
+ const dtsOutfile = changeExtension ( out , ".d.ts" ) ;
663
682
processSourceFile ( dtsOutfile , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false , /*packageId*/ undefined ) ;
664
683
}
665
684
addProjectReferenceRedirects ( parsedRef . commandLine , projectReferenceRedirects ) ;
@@ -758,7 +777,8 @@ namespace ts {
758
777
getConfigFileParsingDiagnostics,
759
778
getResolvedModuleWithFailedLookupLocationsFromCache,
760
779
getProjectReferences,
761
- getResolvedProjectReferences
780
+ getResolvedProjectReferences,
781
+ getProjectReferenceRedirect
762
782
} ;
763
783
764
784
verifyCompilerOptions ( ) ;
@@ -1225,6 +1245,13 @@ namespace ts {
1225
1245
}
1226
1246
resolvedTypeReferenceDirectives = oldProgram . getResolvedTypeReferenceDirectives ( ) ;
1227
1247
resolvedProjectReferences = oldProgram . getResolvedProjectReferences ( ) ;
1248
+ if ( resolvedProjectReferences ) {
1249
+ resolvedProjectReferences . forEach ( ref => {
1250
+ if ( ref ) {
1251
+ addProjectReferenceRedirects ( ref . commandLine , projectReferenceRedirects ) ;
1252
+ }
1253
+ } ) ;
1254
+ }
1228
1255
1229
1256
sourceFileToPackageName = oldProgram . sourceFileToPackageName ;
1230
1257
redirectTargetsMap = oldProgram . redirectTargetsMap ;
@@ -1280,12 +1307,13 @@ namespace ts {
1280
1307
const ref = projectReferences [ i ] ;
1281
1308
const resolvedRefOpts = resolvedProjectReferences ! [ i ] ! . commandLine ;
1282
1309
if ( ref . prepend && resolvedRefOpts && resolvedRefOpts . options ) {
1310
+ const out = resolvedRefOpts . options . outFile || resolvedRefOpts . options . out ;
1283
1311
// Upstream project didn't have outFile set -- skip (error will have been issued earlier)
1284
- if ( ! resolvedRefOpts . options . outFile ) continue ;
1312
+ if ( ! out ) continue ;
1285
1313
1286
- const dtsFilename = changeExtension ( resolvedRefOpts . options . outFile , ".d.ts" ) ;
1287
- const js = host . readFile ( resolvedRefOpts . options . outFile ) || `/* Input file ${ resolvedRefOpts . options . outFile } was missing */\r\n` ;
1288
- const jsMapPath = resolvedRefOpts . options . outFile + ".map" ; // TODO: try to read sourceMappingUrl comment from the file
1314
+ const dtsFilename = changeExtension ( out , ".d.ts" ) ;
1315
+ const js = host . readFile ( out ) || `/* Input file ${ out } was missing */\r\n` ;
1316
+ const jsMapPath = out + ".map" ; // TODO: try to read sourceMappingUrl comment from the file
1289
1317
const jsMap = host . readFile ( jsMapPath ) ;
1290
1318
const dts = host . readFile ( dtsFilename ) || `/* Input file ${ dtsFilename } was missing */\r\n` ;
1291
1319
const dtsMapPath = dtsFilename + ".map" ;
@@ -2427,9 +2455,10 @@ namespace ts {
2427
2455
createDiagnosticForReference ( i , Diagnostics . Referenced_project_0_must_have_setting_composite_Colon_true , ref . path ) ;
2428
2456
}
2429
2457
if ( ref . prepend ) {
2430
- if ( resolvedRefOpts . outFile ) {
2431
- if ( ! host . fileExists ( resolvedRefOpts . outFile ) ) {
2432
- createDiagnosticForReference ( i , Diagnostics . Output_file_0_from_project_1_does_not_exist , resolvedRefOpts . outFile , ref . path ) ;
2458
+ const out = resolvedRefOpts . outFile || resolvedRefOpts . out ;
2459
+ if ( out ) {
2460
+ if ( ! host . fileExists ( out ) ) {
2461
+ createDiagnosticForReference ( i , Diagnostics . Output_file_0_from_project_1_does_not_exist , out , ref . path ) ;
2433
2462
}
2434
2463
}
2435
2464
else {
0 commit comments