@@ -29,6 +29,9 @@ namespace ts {
29
29
preserveWatchOutput ?: boolean ;
30
30
listEmittedFiles ?: boolean ;
31
31
listFiles ?: boolean ;
32
+ pretty ?: boolean ;
33
+
34
+ traceResolution ?: boolean ;
32
35
}
33
36
34
37
enum BuildResultFlags {
@@ -316,7 +319,7 @@ namespace ts {
316
319
return fileExtensionIs ( fileName , Extension . Dts ) ;
317
320
}
318
321
319
- export interface SolutionBuilderHost extends CompilerHost {
322
+ export interface SolutionBuilderHostBase extends CompilerHost {
320
323
getModifiedTime ( fileName : string ) : Date | undefined ;
321
324
setModifiedTime ( fileName : string , date : Date ) : void ;
322
325
deleteFile ( fileName : string ) : void ;
@@ -325,13 +328,18 @@ namespace ts {
325
328
reportSolutionBuilderStatus : DiagnosticReporter ;
326
329
}
327
330
328
- export interface SolutionBuilderWithWatchHost extends SolutionBuilderHost , WatchHost {
331
+ export interface SolutionBuilderHost extends SolutionBuilderHostBase {
332
+ reportErrorSummary ?: ReportEmitErrorSummary ;
333
+ }
334
+
335
+ export interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase , WatchHost {
329
336
}
330
337
331
338
export interface SolutionBuilder {
332
339
buildAllProjects ( ) : ExitStatus ;
333
340
cleanAllProjects ( ) : ExitStatus ;
334
341
342
+ // TODO:: All the below ones should technically only be in watch mode. but thats for later time
335
343
/*@internal */ resolveProjectName ( name : string ) : ResolvedConfigFileName ;
336
344
/*@internal */ getUpToDateStatusOfFile ( configFileName : ResolvedConfigFileName ) : UpToDateStatus ;
337
345
/*@internal */ getBuildGraph ( configFileNames : ReadonlyArray < string > ) : DependencyGraph ;
@@ -340,7 +348,9 @@ namespace ts {
340
348
/*@internal */ buildInvalidatedProject ( ) : void ;
341
349
342
350
/*@internal */ resetBuildContext ( opts ?: BuildOptions ) : void ;
351
+ }
343
352
353
+ export interface SolutionBuilderWithWatch extends SolutionBuilder {
344
354
/*@internal */ startWatching ( ) : void ;
345
355
}
346
356
@@ -355,8 +365,8 @@ namespace ts {
355
365
} ;
356
366
}
357
367
358
- export function createSolutionBuilderHost ( system = sys , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter ) {
359
- const host = createCompilerHostWorker ( { } , /*setParentNodes*/ undefined , system ) as SolutionBuilderHost ;
368
+ function createSolutionBuilderHostBase ( system = sys , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter ) {
369
+ const host = createCompilerHostWorker ( { } , /*setParentNodes*/ undefined , system ) as SolutionBuilderHostBase ;
360
370
host . getModifiedTime = system . getModifiedTime ? path => system . getModifiedTime ! ( path ) : ( ) => undefined ;
361
371
host . setModifiedTime = system . setModifiedTime ? ( path , date ) => system . setModifiedTime ! ( path , date ) : noop ;
362
372
host . deleteFile = system . deleteFile ? path => system . deleteFile ! ( path ) : noop ;
@@ -365,8 +375,14 @@ namespace ts {
365
375
return host ;
366
376
}
367
377
368
- export function createSolutionBuilderWithWatchHost ( system = sys , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter , reportWatchStatus ?: WatchStatusReporter ) {
369
- const host = createSolutionBuilderHost ( system , reportDiagnostic , reportSolutionBuilderStatus ) as SolutionBuilderWithWatchHost ;
378
+ export function createSolutionBuilderHost ( system = sys , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter , reportErrorSummary ?: ReportEmitErrorSummary ) {
379
+ const host = createSolutionBuilderHostBase ( system , reportDiagnostic , reportSolutionBuilderStatus ) as SolutionBuilderHost ;
380
+ host . reportErrorSummary = reportErrorSummary ;
381
+ return host ;
382
+ }
383
+
384
+ export function createSolutionBuilderWithWatchHost ( system ?: System , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter , reportWatchStatus ?: WatchStatusReporter ) {
385
+ const host = createSolutionBuilderHostBase ( system , reportDiagnostic , reportSolutionBuilderStatus ) as SolutionBuilderWithWatchHost ;
370
386
const watchHost = createWatchHost ( system , reportWatchStatus ) ;
371
387
host . onWatchStatusChange = watchHost . onWatchStatusChange ;
372
388
host . watchFile = watchHost . watchFile ;
@@ -390,7 +406,9 @@ namespace ts {
390
406
* TODO: use SolutionBuilderWithWatchHost => watchedSolution
391
407
* use SolutionBuilderHost => Solution
392
408
*/
393
- export function createSolutionBuilder ( host : SolutionBuilderHost , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder {
409
+ export function createSolutionBuilder ( host : SolutionBuilderHost , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder ;
410
+ export function createSolutionBuilder ( host : SolutionBuilderWithWatchHost , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilderWithWatch ;
411
+ export function createSolutionBuilder ( host : SolutionBuilderHost | SolutionBuilderWithWatchHost , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilderWithWatch {
394
412
const hostWithWatch = host as SolutionBuilderWithWatchHost ;
395
413
const currentDirectory = host . getCurrentDirectory ( ) ;
396
414
const getCanonicalFileName = createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -803,9 +821,7 @@ namespace ts {
803
821
globalDependencyGraph = undefined ;
804
822
}
805
823
projectStatus . removeKey ( resolved ) ;
806
- if ( options . watch ) {
807
- diagnostics . removeKey ( resolved ) ;
808
- }
824
+ diagnostics . removeKey ( resolved ) ;
809
825
810
826
addProjToQueue ( resolved , reloadLevel ) ;
811
827
}
@@ -874,16 +890,21 @@ namespace ts {
874
890
}
875
891
876
892
function reportErrorSummary ( ) {
877
- if ( options . watch ) {
893
+ if ( options . watch || ( host as SolutionBuilderHost ) . reportErrorSummary ) {
878
894
// Report errors from the other projects
879
895
getGlobalDependencyGraph ( ) . buildQueue . forEach ( project => {
880
896
if ( ! projectErrorsReported . hasKey ( project ) ) {
881
897
reportErrors ( diagnostics . getValue ( project ) || emptyArray ) ;
882
898
}
883
899
} ) ;
884
900
let totalErrors = 0 ;
885
- diagnostics . forEach ( singleProjectErrors => totalErrors += singleProjectErrors . filter ( diagnostic => diagnostic . category === DiagnosticCategory . Error ) . length ) ;
886
- reportWatchStatus ( totalErrors === 1 ? Diagnostics . Found_1_error_Watching_for_file_changes : Diagnostics . Found_0_errors_Watching_for_file_changes , totalErrors ) ;
901
+ diagnostics . forEach ( singleProjectErrors => totalErrors += getErrorCountForSummary ( singleProjectErrors ) ) ;
902
+ if ( options . watch ) {
903
+ reportWatchStatus ( getWatchErrorSummaryDiagnosticMessage ( totalErrors ) , totalErrors ) ;
904
+ }
905
+ else {
906
+ ( host as SolutionBuilderHost ) . reportErrorSummary ! ( totalErrors ) ;
907
+ }
887
908
}
888
909
}
889
910
@@ -1066,9 +1087,7 @@ namespace ts {
1066
1087
type : UpToDateStatusType . UpToDate ,
1067
1088
newestDeclarationFileContentChangedTime : anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime
1068
1089
} ;
1069
- if ( options . watch ) {
1070
- diagnostics . removeKey ( proj ) ;
1071
- }
1090
+ diagnostics . removeKey ( proj ) ;
1072
1091
projectStatus . setValue ( proj , status ) ;
1073
1092
return resultFlags ;
1074
1093
@@ -1207,10 +1226,8 @@ namespace ts {
1207
1226
1208
1227
function reportAndStoreErrors ( proj : ResolvedConfigFileName , errors : ReadonlyArray < Diagnostic > ) {
1209
1228
reportErrors ( errors ) ;
1210
- if ( options . watch ) {
1211
- projectErrorsReported . setValue ( proj , true ) ;
1212
- diagnostics . setValue ( proj , errors ) ;
1213
- }
1229
+ projectErrorsReported . setValue ( proj , true ) ;
1230
+ diagnostics . setValue ( proj , errors ) ;
1214
1231
}
1215
1232
1216
1233
function reportErrors ( errors : ReadonlyArray < Diagnostic > ) {
0 commit comments