Skip to content

Commit ffa64e8

Browse files
committed
Set program as affected if emitting/diagnostics for whole program
1 parent e102fee commit ffa64e8

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/compiler/builder.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ namespace ts {
334334
/**
335335
* Returns the result with affected file
336336
*/
337-
function toAffectedFileResult<T>(result: T, affectedFile?: SourceFile): AffectedFileResult<T> {
338-
return { result, affectedFile };
337+
function toAffectedFileResult<T>(result: T, affected: SourceFile | Program): AffectedFileResult<T> {
338+
return { result, affected };
339339
}
340340

341341
/**
@@ -350,7 +350,10 @@ namespace ts {
350350
}
351351
else if (affectedFile === programOfThisState) {
352352
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
353-
return toAffectedFileResult(programOfThisState.emit(/*targetSourceFile*/ undefined, writeFileCallback, cancellationToken, /*emitOnlyDtsFiles*/ false, customTransformers));
353+
return toAffectedFileResult(
354+
programOfThisState.emit(/*targetSourceFile*/ undefined, writeFileCallback, cancellationToken, /*emitOnlyDtsFiles*/ false, customTransformers),
355+
programOfThisState
356+
);
354357
}
355358

356359
// Emit the affected file
@@ -374,7 +377,10 @@ namespace ts {
374377
}
375378
else if (affectedFile === programOfThisState) {
376379
// When whole program is affected, get all semantic diagnostics (eg when --out or --outFile is specified)
377-
return toAffectedFileResult(programOfThisState.getSemanticDiagnostics(/*targetSourceFile*/ undefined, cancellationToken));
380+
return toAffectedFileResult(
381+
programOfThisState.getSemanticDiagnostics(/*targetSourceFile*/ undefined, cancellationToken),
382+
programOfThisState
383+
);
378384
}
379385

380386
// Get diagnostics for the affected file if its not ignored
@@ -693,7 +699,7 @@ namespace ts {
693699
text: string;
694700
}
695701

696-
export type AffectedFileResult<T> = { result: T; affectedFile?: SourceFile; } | undefined;
702+
export type AffectedFileResult<T> = { result: T; affected: SourceFile | Program; } | undefined;
697703

698704
export interface BuilderOptions {
699705
getCanonicalFileName: (fileName: string) => string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,7 @@ declare namespace ts {
37733773
}
37743774
type AffectedFileResult<T> = {
37753775
result: T;
3776-
affectedFile?: SourceFile;
3776+
affected: SourceFile | Program;
37773777
} | undefined;
37783778
interface BuilderOptions {
37793779
getCanonicalFileName: (fileName: string) => string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3720,7 +3720,7 @@ declare namespace ts {
37203720
}
37213721
type AffectedFileResult<T> = {
37223722
result: T;
3723-
affectedFile?: SourceFile;
3723+
affected: SourceFile | Program;
37243724
} | undefined;
37253725
interface BuilderOptions {
37263726
getCanonicalFileName: (fileName: string) => string;

0 commit comments

Comments
 (0)