Skip to content

Commit 853b9b1

Browse files
committed
Fix api
1 parent 4a581c1 commit 853b9b1

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace ts {
9898
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
9999
reportSolutionBuilderStatus: DiagnosticReporter;
100100

101-
afterProgramEmitAndDiagnostics?(program: T, host: CompilerHost): void;
101+
afterProgramEmitAndDiagnostics?(program: T, host?: CompilerHost): void;
102102
/*@internal*/ beforeEmitBundle?(config: ParsedCommandLine, host: CompilerHost): void;
103103
/*@internal*/ afterEmitBundle?(config: ParsedCommandLine, host: CompilerHost): void;
104104

src/compiler/watchPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ namespace ts {
141141
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
142142

143143
/** If provided, callback to invoke after every new program creation */
144-
afterProgramCreate?(program: T, host: CompilerHost): void;
144+
afterProgramCreate?(program: T, host?: CompilerHost): void;
145145
}
146146

147147
/**

src/executeCommandLine/executeCommandLine.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ namespace ts {
873873
host.createProgram = (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
874874
Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
875875
if (options !== undefined) {
876-
enableStatisticsAndTracing(sys, options, host!, isBuildMode);
876+
enableStatisticsAndTracing(sys, options, host, isBuildMode);
877877
}
878878
return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
879879
};
@@ -1059,15 +1059,15 @@ namespace ts {
10591059
return system === sys && compilerOptions.generateTrace;
10601060
}
10611061

1062-
function enableStatisticsAndTracing(system: System, compilerOptions: CompilerOptions, host: CompilerHost, isBuildMode: boolean) {
1062+
function enableStatisticsAndTracing(system: System, compilerOptions: CompilerOptions, host: CompilerHost | undefined, isBuildMode: boolean) {
10631063
if (canReportDiagnostics(system, compilerOptions)) {
10641064
performance.enable(system);
10651065
}
10661066
if (canTrace(system, compilerOptions)) {
10671067
startTracing(isBuildMode ? "build" : "project",
10681068
compilerOptions.generateTrace!, compilerOptions.configFilePath);
10691069
}
1070-
if (system === sys) {
1070+
if (system === sys && host) {
10711071
if (compilerOptions.extendedDiagnostics && isIncrementalCompilation(compilerOptions)) {
10721072
createBuildInfoCallbacks(host, compilerOptions);
10731073
}
@@ -1212,7 +1212,7 @@ namespace ts {
12121212
return !(programOrConfig as ParsedCommandLine).options;
12131213
}
12141214

1215-
function reportStatistics(sys: System, programOrConfig: Program | ParsedCommandLine, host: CompilerHost, solutionPerformance: SolutionPerformance | undefined) {
1215+
function reportStatistics(sys: System, programOrConfig: Program | ParsedCommandLine, host: CompilerHost | undefined, solutionPerformance: SolutionPerformance | undefined) {
12161216
const program = isProgram(programOrConfig) ? programOrConfig : undefined;
12171217
const config = isProgram(programOrConfig) ? undefined : programOrConfig;
12181218
const compilerOptions = program ? program.getCompilerOptions() : config!.options;
@@ -1260,7 +1260,7 @@ namespace ts {
12601260
reportCountStatistic("Subtype cache size", caches.subtype);
12611261
reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
12621262
}
1263-
if (host.buildInfoCallbacks) {
1263+
if (host?.buildInfoCallbacks) {
12641264
reportBuildInfoReadOrWriteStatistic(host.buildInfoCallbacks.getRead(), "read");
12651265
reportBuildInfoReadOrWriteStatistic(host.buildInfoCallbacks.getWrite(), "write");
12661266
host.buildInfoCallbacks.close(host);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,7 +5430,7 @@ declare namespace ts {
54305430
/** If provided, use this method to get parsed command lines for referenced projects */
54315431
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
54325432
/** If provided, callback to invoke after every new program creation */
5433-
afterProgramCreate?(program: T, host: CompilerHost): void;
5433+
afterProgramCreate?(program: T, host?: CompilerHost): void;
54345434
}
54355435
/**
54365436
* Host to create watch with root files and options
@@ -5521,7 +5521,7 @@ declare namespace ts {
55215521
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
55225522
reportDiagnostic: DiagnosticReporter;
55235523
reportSolutionBuilderStatus: DiagnosticReporter;
5524-
afterProgramEmitAndDiagnostics?(program: T, host: CompilerHost): void;
5524+
afterProgramEmitAndDiagnostics?(program: T, host?: CompilerHost): void;
55255525
}
55265526
interface SolutionBuilderHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T> {
55275527
reportErrorSummary?: ReportEmitErrorSummary;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,7 +5430,7 @@ declare namespace ts {
54305430
/** If provided, use this method to get parsed command lines for referenced projects */
54315431
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
54325432
/** If provided, callback to invoke after every new program creation */
5433-
afterProgramCreate?(program: T, host: CompilerHost): void;
5433+
afterProgramCreate?(program: T, host?: CompilerHost): void;
54345434
}
54355435
/**
54365436
* Host to create watch with root files and options
@@ -5521,7 +5521,7 @@ declare namespace ts {
55215521
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
55225522
reportDiagnostic: DiagnosticReporter;
55235523
reportSolutionBuilderStatus: DiagnosticReporter;
5524-
afterProgramEmitAndDiagnostics?(program: T, host: CompilerHost): void;
5524+
afterProgramEmitAndDiagnostics?(program: T, host?: CompilerHost): void;
55255525
}
55265526
interface SolutionBuilderHost<T extends BuilderProgram> extends SolutionBuilderHostBase<T> {
55275527
reportErrorSummary?: ReportEmitErrorSummary;

0 commit comments

Comments
 (0)