@@ -341,7 +341,7 @@ namespace ts {
341
341
342
342
/*@internal */ resolveProjectName ( name : string ) : ResolvedConfigFileName ;
343
343
/*@internal */ getUpToDateStatusOfFile ( configFileName : ResolvedConfigFileName ) : UpToDateStatus ;
344
- /*@internal */ getBuildGraph ( configFileNames : ReadonlyArray < string > ) : DependencyGraph | undefined ;
344
+ /*@internal */ getBuildGraph ( configFileNames : ReadonlyArray < string > ) : DependencyGraph ;
345
345
346
346
/*@internal */ invalidateProject ( configFileName : string , reloadLevel ?: ConfigFileProgramReloadLevel ) : void ;
347
347
/*@internal */ buildInvalidatedProject ( ) : void ;
@@ -404,7 +404,7 @@ namespace ts {
404
404
/** Map from config file name to up-to-date status */
405
405
const projectStatus = createFileMap < UpToDateStatus > ( toPath ) ;
406
406
const missingRoots = createMap < true > ( ) ;
407
- let globalDependencyGraph : DependencyGraph | false | undefined ;
407
+ let globalDependencyGraph : DependencyGraph | undefined ;
408
408
409
409
// Watch state
410
410
// TODO(shkamat): this should be really be diagnostics but thats for later time
@@ -504,12 +504,7 @@ namespace ts {
504
504
}
505
505
506
506
function startWatching ( ) {
507
- const graph = getGlobalDependencyGraph ( ) ! ;
508
- if ( ! graph . buildQueue ) {
509
- // Everything is broken - we don't even know what to watch. Give up.
510
- return ;
511
- }
512
-
507
+ const graph = getGlobalDependencyGraph ( ) ;
513
508
for ( const resolved of graph . buildQueue ) {
514
509
const cfg = parseConfigFile ( resolved ) ;
515
510
if ( cfg ) {
@@ -627,10 +622,7 @@ namespace ts {
627
622
}
628
623
629
624
function getGlobalDependencyGraph ( ) {
630
- if ( globalDependencyGraph === undefined ) {
631
- globalDependencyGraph = getBuildGraph ( rootNames ) || false ;
632
- }
633
- return globalDependencyGraph || undefined ;
625
+ return globalDependencyGraph || ( globalDependencyGraph = getBuildGraph ( rootNames ) ) ;
634
626
}
635
627
636
628
function getUpToDateStatus ( project : ParsedCommandLine | undefined ) : UpToDateStatus {
@@ -826,10 +818,7 @@ namespace ts {
826
818
827
819
if ( addProjToQueue ( resolved , reloadLevel ) ) {
828
820
// TODO: instead of adding the dependent project to queue right away postpone this
829
- const dependencyGraph = getGlobalDependencyGraph ( ) ;
830
- if ( dependencyGraph ) {
831
- queueBuildForDownstreamReferences ( resolved , dependencyGraph ) ;
832
- }
821
+ queueBuildForDownstreamReferences ( resolved , getGlobalDependencyGraph ( ) ) ;
833
822
}
834
823
}
835
824
@@ -950,49 +939,36 @@ namespace ts {
950
939
buildSingleProject ( resolved ) ;
951
940
}
952
941
953
- function createDependencyGraph ( roots : ResolvedConfigFileName [ ] ) : DependencyGraph | undefined {
954
- const temporaryMarks : { [ path : string ] : true } = { } ;
955
- const permanentMarks : { [ path : string ] : true } = { } ;
942
+ function createDependencyGraph ( roots : ResolvedConfigFileName [ ] ) : DependencyGraph {
943
+ const temporaryMarks = createFileMap < true > ( toPath ) ;
944
+ const permanentMarks = createFileMap < true > ( toPath ) ;
956
945
const circularityReportStack : string [ ] = [ ] ;
957
946
const buildOrder : ResolvedConfigFileName [ ] = [ ] ;
958
947
const graph = createDependencyMapper ( toPath ) ;
959
-
960
- let hadError = false ;
961
-
962
948
for ( const root of roots ) {
963
949
visit ( root ) ;
964
950
}
965
951
966
- if ( hadError ) {
967
- return undefined ;
968
- }
969
-
970
952
return {
971
953
buildQueue : buildOrder ,
972
- dependencyMap : graph
954
+ dependencyMap : graph ,
973
955
} ;
974
956
975
957
function visit ( projPath : ResolvedConfigFileName , inCircularContext = false ) {
976
958
// Already visited
977
- if ( permanentMarks [ projPath ] ) return ;
959
+ if ( permanentMarks . hasKey ( projPath ) ) return ;
978
960
// Circular
979
- if ( temporaryMarks [ projPath ] ) {
961
+ if ( temporaryMarks . hasKey ( projPath ) ) {
980
962
if ( ! inCircularContext ) {
981
- hadError = true ;
982
- // TODO(shkamat): Account for this error
983
963
reportStatus ( Diagnostics . Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0 , circularityReportStack . join ( "\r\n" ) ) ;
984
964
return ;
985
965
}
986
966
}
987
967
988
- temporaryMarks [ projPath ] = true ;
968
+ temporaryMarks . setValue ( projPath , true ) ;
989
969
circularityReportStack . push ( projPath ) ;
990
970
const parsed = parseConfigFile ( projPath ) ;
991
- if ( parsed === undefined ) {
992
- hadError = true ;
993
- return ;
994
- }
995
- if ( parsed . projectReferences ) {
971
+ if ( parsed && parsed . projectReferences ) {
996
972
for ( const ref of parsed . projectReferences ) {
997
973
const resolvedRefPath = resolveProjectName ( ref . path ) ;
998
974
visit ( resolvedRefPath , inCircularContext || ref . circular ) ;
@@ -1001,7 +977,7 @@ namespace ts {
1001
977
}
1002
978
1003
979
circularityReportStack . pop ( ) ;
1004
- permanentMarks [ projPath ] = true ;
980
+ permanentMarks . setValue ( projPath , true ) ;
1005
981
buildOrder . push ( projPath ) ;
1006
982
}
1007
983
}
@@ -1135,11 +1111,9 @@ namespace ts {
1135
1111
projectStatus . setValue ( proj . options . configFilePath as ResolvedConfigFilePath , { type : UpToDateStatusType . UpToDate , newestDeclarationFileContentChangedTime : priorNewestUpdateTime } as UpToDateStatus ) ;
1136
1112
}
1137
1113
1138
- function getFilesToClean ( ) : string [ ] | undefined {
1114
+ function getFilesToClean ( ) : string [ ] {
1139
1115
// Get the same graph for cleaning we'd use for building
1140
1116
const graph = getGlobalDependencyGraph ( ) ;
1141
- if ( graph === undefined ) return undefined ;
1142
-
1143
1117
const filesToDelete : string [ ] = [ ] ;
1144
1118
for ( const proj of graph . buildQueue ) {
1145
1119
const parsed = parseConfigFile ( proj ) ;
@@ -1159,11 +1133,6 @@ namespace ts {
1159
1133
1160
1134
function cleanAllProjects ( ) {
1161
1135
const filesToDelete = getFilesToClean ( ) ;
1162
- if ( filesToDelete === undefined ) {
1163
- reportStatus ( Diagnostics . Skipping_clean_because_not_all_projects_could_be_located ) ;
1164
- return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
1165
- }
1166
-
1167
1136
if ( options . dry ) {
1168
1137
reportStatus ( Diagnostics . A_non_dry_build_would_delete_the_following_files_Colon_0 , filesToDelete . map ( f => `\r\n * ${ f } ` ) . join ( "" ) ) ;
1169
1138
return ExitStatus . Success ;
@@ -1187,11 +1156,6 @@ namespace ts {
1187
1156
function buildAllProjects ( ) : ExitStatus {
1188
1157
if ( options . watch ) { reportWatchStatus ( Diagnostics . Starting_compilation_in_watch_mode ) ; }
1189
1158
const graph = getGlobalDependencyGraph ( ) ;
1190
- if ( graph === undefined ) {
1191
- reportErrorSummary ( ) ;
1192
- return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
1193
- }
1194
-
1195
1159
const queue = graph . buildQueue ;
1196
1160
reportBuildQueue ( graph ) ;
1197
1161
let anyFailed = false ;
0 commit comments