Skip to content

Commit 61fc9b9

Browse files
committed
Rename Watch.synchronizeProgram to getProgram and return the updated program as part of this api
1 parent 3dda217 commit 61fc9b9

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/compiler/watch.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ namespace ts {
212212
}
213213

214214
export interface Watch {
215-
/** Synchronize the program with the changes */
216-
synchronizeProgram(): void;
215+
/** Synchronize with host and get updated program */
216+
getProgram(): Program;
217217
/** Gets the existing program without synchronizing with changes on host */
218218
/*@internal*/
219219
getExistingProgram(): Program;
@@ -360,10 +360,10 @@ namespace ts {
360360
watchConfigFileWildCardDirectories();
361361

362362
return configFileName ?
363-
{ getExistingProgram: () => program, synchronizeProgram } :
364-
{ getExistingProgram: () => program, synchronizeProgram, updateRootFileNames };
363+
{ getExistingProgram: () => program, getProgram: synchronizeProgram } :
364+
{ getExistingProgram: () => program, getProgram: synchronizeProgram, updateRootFileNames };
365365

366-
function synchronizeProgram() {
366+
function synchronizeProgram(): Program {
367367
writeLog(`Synchronizing program`);
368368

369369
if (hasChangedCompilerOptions) {
@@ -375,7 +375,7 @@ namespace ts {
375375

376376
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution();
377377
if (isProgramUptoDate(program, rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames)) {
378-
return;
378+
return program;
379379
}
380380

381381
beforeProgramCreate(compilerOptions);
@@ -411,6 +411,7 @@ namespace ts {
411411

412412
afterProgramCreate(directoryStructureHost, program);
413413
reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
414+
return program;
414415
}
415416

416417
function updateRootFileNames(files: string[]) {
@@ -569,7 +570,8 @@ namespace ts {
569570
case ConfigFileProgramReloadLevel.Full:
570571
return reloadConfigFile();
571572
default:
572-
return synchronizeProgram();
573+
synchronizeProgram();
574+
return;
573575
}
574576
}
575577

tests/baselines/reference/api/typescript.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,8 +3850,8 @@ declare namespace ts {
38503850
onConfigFileDiagnostic(diagnostic: Diagnostic): void;
38513851
}
38523852
interface Watch {
3853-
/** Synchronize the program with the changes */
3854-
synchronizeProgram(): void;
3853+
/** Synchronize with host and get updated program */
3854+
getProgram(): Program;
38553855
}
38563856
/**
38573857
* Creates the watch what generates program using the config file

0 commit comments

Comments
 (0)