@@ -234,6 +234,7 @@ namespace ts {
234234 export interface SolutionBuilderHostBase < T extends BuilderProgram > extends ProgramHost < T > {
235235 getModifiedTime ( fileName : string ) : Date | undefined ;
236236 setModifiedTime ( fileName : string , date : Date ) : void ;
237+ deleteFile ( fileName : string ) : void ;
237238
238239 reportDiagnostic : DiagnosticReporter ; // Technically we want to move it out and allow steps of actions on Solution, but for now just merge stuff in build host here
239240 reportSolutionBuilderStatus : DiagnosticReporter ;
@@ -247,7 +248,6 @@ namespace ts {
247248 }
248249
249250 export interface SolutionBuilderHost < T extends BuilderProgram > extends SolutionBuilderHostBase < T > {
250- deleteFile ( fileName : string ) : void ;
251251 reportErrorSummary ?: ReportEmitErrorSummary ;
252252 }
253253
@@ -267,11 +267,6 @@ namespace ts {
267267 /*@internal */ buildNextInvalidatedProject ( ) : void ;
268268 }
269269
270- export interface SolutionBuilderWithWatch {
271- build ( project ?: string , cancellationToken ?: CancellationToken ) : ExitStatus ;
272- /*@internal */ startWatching ( ) : void ;
273- }
274-
275270 interface InvalidatedProject {
276271 project : ResolvedConfigFileName ;
277272 projectPath : ResolvedConfigFilePath ;
@@ -294,14 +289,14 @@ namespace ts {
294289 const host = createProgramHost ( system , createProgram ) as SolutionBuilderHostBase < T > ;
295290 host . getModifiedTime = system . getModifiedTime ? path => system . getModifiedTime ! ( path ) : returnUndefined ;
296291 host . setModifiedTime = system . setModifiedTime ? ( path , date ) => system . setModifiedTime ! ( path , date ) : noop ;
292+ host . deleteFile = system . deleteFile ? path => system . deleteFile ! ( path ) : noop ;
297293 host . reportDiagnostic = reportDiagnostic || createDiagnosticReporter ( system ) ;
298294 host . reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter ( system ) ;
299295 return host ;
300296 }
301297
302298 export function createSolutionBuilderHost < T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram > ( system = sys , createProgram ?: CreateProgram < T > , reportDiagnostic ?: DiagnosticReporter , reportSolutionBuilderStatus ?: DiagnosticReporter , reportErrorSummary ?: ReportEmitErrorSummary ) {
303299 const host = createSolutionBuilderHostBase ( system , createProgram , reportDiagnostic , reportSolutionBuilderStatus ) as SolutionBuilderHost < T > ;
304- host . deleteFile = system . deleteFile ? path => system . deleteFile ! ( path ) : noop ;
305300 host . reportErrorSummary = reportErrorSummary ;
306301 return host ;
307302 }
@@ -325,7 +320,7 @@ namespace ts {
325320 return createSolutionBuilderWorker ( /*watch*/ false , host , rootNames , defaultOptions ) ;
326321 }
327322
328- export function createSolutionBuilderWithWatch < T extends BuilderProgram > ( host : SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilderWithWatch {
323+ export function createSolutionBuilderWithWatch < T extends BuilderProgram > ( host : SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder {
329324 return createSolutionBuilderWorker ( /*watch*/ true , host , rootNames , defaultOptions ) ;
330325 }
331326
@@ -334,8 +329,8 @@ namespace ts {
334329 * can dynamically add/remove other projects based on changes on the rootNames' references
335330 */
336331 function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : false , host : SolutionBuilderHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder ;
337- function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : true , host : SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilderWithWatch ;
338- function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder | SolutionBuilderWithWatch {
332+ function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : true , host : SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder ;
333+ function createSolutionBuilderWorker < T extends BuilderProgram > ( watch : boolean , hostOrHostWithWatch : SolutionBuilderHost < T > | SolutionBuilderWithWatchHost < T > , rootNames : ReadonlyArray < string > , defaultOptions : BuildOptions ) : SolutionBuilder {
339334 const host = hostOrHostWithWatch as SolutionBuilderHost < T > ;
340335 const hostWithWatch = hostOrHostWithWatch as SolutionBuilderWithWatchHost < T > ;
341336 const currentDirectory = host . getCurrentDirectory ( ) ;
@@ -395,21 +390,16 @@ namespace ts {
395390
396391 let allProjectBuildPending = true ;
397392 let needsSummary = true ;
398- // let watchAllProjectsPending = watch;
399-
400- return watch ?
401- {
402- build,
403- startWatching
404- } :
405- {
406- build,
407- clean,
408- getBuildOrder,
409- getUpToDateStatusOfProject,
410- invalidateProject,
411- buildNextInvalidatedProject,
412- } ;
393+ let watchAllProjectsPending = watch ;
394+
395+ return {
396+ build,
397+ clean,
398+ getBuildOrder,
399+ getUpToDateStatusOfProject,
400+ invalidateProject,
401+ buildNextInvalidatedProject,
402+ } ;
413403
414404 function toPath ( fileName : string ) {
415405 return ts . toPath ( fileName , currentDirectory , getCanonicalFileName ) ;
@@ -1469,6 +1459,10 @@ namespace ts {
14691459 disableCache ( ) ;
14701460 reportErrorSummary ( ) ;
14711461 }
1462+ if ( watchAllProjectsPending ) {
1463+ watchAllProjectsPending = false ;
1464+ startWatching ( ) ;
1465+ }
14721466 break ;
14731467 }
14741468
0 commit comments