Skip to content

Commit ac107c9

Browse files
committed
Skeleton for buildinfo program
1 parent 42d1004 commit ac107c9

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/compiler/builder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ namespace ts {
868868
rootNames: newProgramOrRootNames,
869869
options: hostOrOptions as CompilerOptions,
870870
host: oldProgramOrHost as CompilerHost,
871-
oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
871+
oldProgram: oldProgram?.getProgramOrProgramFromBuildInfoOrUndefined(),
872872
configFileParsingDiagnostics,
873873
projectReferences
874874
});
@@ -1210,6 +1210,8 @@ namespace ts {
12101210
restoreState: noop,
12111211
getProgram: notImplemented,
12121212
getProgramOrUndefined: returnUndefined,
1213+
// TODO::
1214+
getProgramOrProgramFromBuildInfoOrUndefined: returnUndefined,
12131215
releaseProgram: noop,
12141216
getCompilerOptions: () => state.compilerOptions,
12151217
getSourceFile: notImplemented,
@@ -1245,6 +1247,8 @@ namespace ts {
12451247
restoreState: noop,
12461248
getProgram,
12471249
getProgramOrUndefined: () => getState().program,
1250+
// TODO::
1251+
getProgramOrProgramFromBuildInfoOrUndefined: () => getState().program,
12481252
releaseProgram: () => getState().program = undefined,
12491253
getCompilerOptions: () => getState().compilerOptions,
12501254
getSourceFile: fileName => getProgram().getSourceFile(fileName),

src/compiler/builderPublic.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ namespace ts {
3636
*/
3737
/*@internal*/
3838
getProgramOrUndefined(): Program | undefined;
39+
/**
40+
* Returns current program that could be undefined if the program was released
41+
*/
42+
/*@internal*/
43+
getProgramOrProgramFromBuildInfoOrUndefined(): Program | ProgramFromBuildInfo | undefined;
3944
/**
4045
* Releases reference to the program, making all the other operations that need program to fail.
4146
*/

src/compiler/resolutionCache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ namespace ts {
362362

363363
// All the resolutions in this file are invalidated if this file wasnt resolved using same redirect
364364
const program = resolutionHost.getCurrentProgram();
365+
// TODO later to see if we need to hydrate resolution cache and if we need to be able to answer this
365366
const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
366367
const unmatchedRedirects = oldRedirect ?
367368
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6060,7 +6060,7 @@ namespace ts {
60606060
}
60616061

60626062
/* @internal */
6063-
export type CreateProgramOptionsWithProgramFromBuildInfo = Omit<CreateProgramOptions, "oldProgram"> & { oldProgram: ProgramFromBuildInfo; };
6063+
export type CreateProgramOptionsWithProgramFromBuildInfo = Omit<CreateProgramOptions, "oldProgram"> & { oldProgram: ProgramFromBuildInfo | Program | undefined; };
60646064

60656065
/* @internal */
60666066
export interface CommandLineOptionBase {

src/compiler/watchUtilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ namespace ts {
388388

389389
// just check if sourceFile with the name exists
390390
const filePathWithoutExtension = removeFileExtension(fileOrDirectoryPath);
391-
const realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program;
391+
const realProgram = isBuilderProgram(program) ? program.getProgramOrProgramFromBuildInfoOrUndefined() : program;
392392
if (hasSourceFile((filePathWithoutExtension + Extension.Ts) as Path) ||
393393
hasSourceFile((filePathWithoutExtension + Extension.Tsx) as Path)) {
394394
writeLog(`Project: ${configFileName} Detected output file: ${fileOrDirectory}`);

0 commit comments

Comments
 (0)