Skip to content

Commit 38baba7

Browse files
committed
renames to cleanPersistedProgram
1 parent 3921c66 commit 38baba7

File tree

21 files changed

+219
-61
lines changed

21 files changed

+219
-61
lines changed

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ namespace ts {
275275
description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
276276
},
277277
{
278-
name: "cleanResolutions",
278+
name: "cleanPersistedProgram",
279279
type: "boolean",
280280
isCommandLineOnly: true,
281281
category: Diagnostics.Advanced_Options,
282-
description: Diagnostics.Save_module_and_type_reference_directive_resolution_information_in_tsbuildinfo_file,
282+
description: Diagnostics.Clean_persisted_program_information_in_tsbuildinfo_file,
283283
},
284284
];
285285

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4761,7 +4761,7 @@
47614761
"category": "Message",
47624762
"code": 6239
47634763
},
4764-
"Clean module and type reference directive resolution information in '.tsbuildinfo' file.": {
4764+
"Clean persisted program information in '.tsbuildinfo' file.": {
47654765
"category": "Message",
47664766
"code": 6240
47674767
},

src/compiler/tsbuildPublic.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ts {
1818
/*@internal*/ pretty?: boolean;
1919
incremental?: boolean;
2020
assumeChangesOnlyAffectDirectDependencies?: boolean;
21-
/*@internal*/ cleanResolutions?: boolean;
21+
/*@internal*/ cleanPersistedProgram?: boolean;
2222

2323
traceResolution?: boolean;
2424
/* @internal */ diagnostics?: boolean;
@@ -134,10 +134,10 @@ namespace ts {
134134
export interface SolutionBuilder<T extends BuilderProgram> {
135135
build(project?: string, cancellationToken?: CancellationToken): ExitStatus;
136136
clean(project?: string): ExitStatus;
137-
cleanResolutions(project?: string): ExitStatus;
137+
cleanPersistedProgram(project?: string): ExitStatus;
138138
buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus;
139139
cleanReferences(project?: string): ExitStatus;
140-
cleanResolutionsOfReferences(project?: string): ExitStatus;
140+
cleanPersistedProgramOfReferences(project?: string): ExitStatus;
141141
getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject<T> | undefined;
142142

143143
// Currently used for testing but can be made public if needed:
@@ -1735,7 +1735,7 @@ namespace ts {
17351735
return ExitStatus.Success;
17361736
}
17371737

1738-
function cleanResolutions(state: SolutionBuilderState, project?: string, onlyReferences?: boolean) {
1738+
function cleanPersistedProgram(state: SolutionBuilderState, project?: string, onlyReferences?: boolean) {
17391739
const buildOrder = getBuildOrderFor(state, project, onlyReferences);
17401740
if (!buildOrder) return ExitStatus.InvalidProject_OutputsSkipped;
17411741

@@ -1750,7 +1750,7 @@ namespace ts {
17501750
const resolvedPath = toResolvedConfigFilePath(state, proj);
17511751
const parsed = parseConfigFile(state, proj, resolvedPath);
17521752
if (parsed) {
1753-
diagnostics += cleanResolutionsOfTsBuildInfoAndReportError(
1753+
diagnostics += cleanPersistedProgramOfTsBuildInfoAndReportError(
17541754
parsed.options,
17551755
state.compilerHost,
17561756
err => state.host.reportDiagnostic(err),
@@ -1943,10 +1943,10 @@ namespace ts {
19431943
return {
19441944
build: (project, cancellationToken) => build(state, project, cancellationToken),
19451945
clean: project => clean(state, project),
1946-
cleanResolutions: project => cleanResolutions(state, project),
1946+
cleanPersistedProgram: project => cleanPersistedProgram(state, project),
19471947
buildReferences: (project, cancellationToken) => build(state, project, cancellationToken, /*onlyReferences*/ true),
19481948
cleanReferences: project => clean(state, project, /*onlyReferences*/ true),
1949-
cleanResolutionsOfReferences: project => cleanResolutions(state, project, /*onlyReferences*/ true),
1949+
cleanPersistedProgramOfReferences: project => cleanPersistedProgram(state, project, /*onlyReferences*/ true),
19501950
getNextInvalidatedProject: cancellationToken => {
19511951
setupInitialBuild(state, cancellationToken);
19521952
return getNextInvalidatedProject(state, getBuildOrder(state), /*reportQueue*/ false);

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6004,7 +6004,7 @@ namespace ts {
60046004
incremental?: boolean;
60056005
tsBuildInfoFile?: string;
60066006
persistResolutions?: string;
6007-
cleanResolutions?: boolean;
6007+
cleanPersistedProgram?: boolean;
60086008
removeComments?: boolean;
60096009
rootDir?: string;
60106010
rootDirs?: string[];

src/compiler/watch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,17 @@ namespace ts {
392392
return ExitStatus.Success;
393393
}
394394

395-
export interface CleanResolutionsOfTsBuildInfoAndReportErrorHost extends CleanResolutionsOfTsBuildInfoHost {
395+
export interface CleanPersistedProgramOfTsBuildInfoAndReportErrorHost extends CleanPersistedProgramOfTsBuildInfoHost {
396396
getCurrentDirectory(): string;
397397
}
398-
export function cleanResolutionsOfTsBuildInfoAndReportError(
398+
export function cleanPersistedProgramOfTsBuildInfoAndReportError(
399399
options: CompilerOptions,
400-
host: CleanResolutionsOfTsBuildInfoAndReportErrorHost,
400+
host: CleanPersistedProgramOfTsBuildInfoAndReportErrorHost,
401401
reportDiagnostic: DiagnosticReporter,
402402
write?: (s: string) => void,
403403
reportSummary?: ReportEmitErrorSummary,
404404
): number {
405-
const { emittedFiles, diagnostics } = cleanResolutionsOfTsBuildInfo(options, host);
405+
const { emittedFiles, diagnostics } = cleanPersistedProgramOfTsBuildInfo(options, host);
406406
diagnostics.forEach(reportDiagnostic);
407407
if (write) {
408408
const currentDir = host.getCurrentDirectory();

src/compiler/watchPublic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ namespace ts {
1616
return createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
1717
}
1818

19-
export interface CleanResolutionsOfTsBuildInfoHost {
19+
export interface CleanPersistedProgramOfTsBuildInfoHost {
2020
readFile(fileName: string): string | undefined;
2121
writeFile: WriteFileCallback;
2222
}
23-
export function cleanResolutionsOfTsBuildInfo(compilerOptions: CompilerOptions, host: CleanResolutionsOfTsBuildInfoHost): EmitResult {
23+
export function cleanPersistedProgramOfTsBuildInfo(compilerOptions: CompilerOptions, host: CleanPersistedProgramOfTsBuildInfoHost): EmitResult {
2424
if (outFileWithoutPersistResolutions(compilerOptions)) return emitSkippedWithNoDiagnostics;
2525
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(compilerOptions);
2626
if (!buildInfoPath) return emitSkippedWithNoDiagnostics;

src/executeCommandLine/executeCommandLine.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ namespace ts {
306306
reportDiagnostic,
307307
configParseResult.options
308308
);
309-
if (commandLineOptions.cleanResolutions) {
309+
if (commandLineOptions.cleanPersistedProgram) {
310310
configParseResult.errors.forEach(reportDiagnostic);
311-
return cleanResolutions(sys, configParseResult.options, reportDiagnostic);
311+
return cleanPersistedProgram(sys, configParseResult.options, reportDiagnostic);
312312
}
313313
if (isWatchSet(configParseResult.options)) {
314314
if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) return;
@@ -349,8 +349,8 @@ namespace ts {
349349
reportDiagnostic,
350350
commandLineOptions
351351
);
352-
if (commandLineOptions.cleanResolutions) {
353-
return cleanResolutions(sys, commandLineOptions, reportDiagnostic);
352+
if (commandLineOptions.cleanPersistedProgram) {
353+
return cleanPersistedProgram(sys, commandLineOptions, reportDiagnostic);
354354
}
355355
if (isWatchSet(commandLineOptions)) {
356356
if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) return;
@@ -483,7 +483,7 @@ namespace ts {
483483
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
484484
}
485485

486-
if (buildOptions.cleanResolutions) {
486+
if (buildOptions.cleanPersistedProgram) {
487487
const buildHost = createSolutionBuilderHost(
488488
sys,
489489
/*createProgram*/ undefined,
@@ -493,7 +493,7 @@ namespace ts {
493493
);
494494
updateSolutionBuilderHost(sys, cb, buildHost);
495495
const builder = createSolutionBuilder(buildHost, projects, buildOptions);
496-
return sys.exit(builder.cleanResolutions());
496+
return sys.exit(builder.cleanPersistedProgram());
497497
}
498498

499499
if (buildOptions.watch) {
@@ -531,8 +531,8 @@ namespace ts {
531531
undefined;
532532
}
533533

534-
function cleanResolutions(sys: System, options: CompilerOptions, reportDiagnostic: DiagnosticReporter) {
535-
const diagnostics = cleanResolutionsOfTsBuildInfoAndReportError(
534+
function cleanPersistedProgram(sys: System, options: CompilerOptions, reportDiagnostic: DiagnosticReporter) {
535+
const diagnostics = cleanPersistedProgramOfTsBuildInfoAndReportError(
536536
options,
537537
sys,
538538
reportDiagnostic,

src/testRunner/unittests/tsbuild/persistResolutions.ts

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace ts {
2-
export function verifyTscPersistsResolutions(input: "--p" | "--b", outFile?: string) {
2+
describe("unittests:: tsbuild:: persistResolutions::", () => {
33
verifyTscSerializedIncrementalEdits({
44
scenario: "persistResolutions",
5-
subScenario: `saves resolution and uses it for new program${outFile ? " with outFile" : ""}`,
5+
subScenario: `saves resolution and uses it for new program`,
66
fs: () => loadProjectFromFiles({
77
"/src/project/src/main.ts": Utils.dedent`
88
import { something } from "./filePresent";
@@ -14,12 +14,11 @@ namespace ts {
1414
composite: true,
1515
persistResolutions: true,
1616
traceResolution: true,
17-
outFile
1817
},
1918
include: ["src/**/*.ts"]
2019
}),
2120
}),
22-
commandLineArgs: [input, "src/project"],
21+
commandLineArgs: ["--b", "src/project"],
2322
incrementalScenarios: [
2423
noChangeRun,
2524
{
@@ -44,7 +43,7 @@ namespace ts {
4443
subScenario: "Clean resolutions",
4544
buildKind: BuildKind.IncrementalDtsChange,
4645
modifyFs: noop,
47-
commandLineArgs: [input, "src/project", "--cleanResolutions"]
46+
commandLineArgs: ["--b", "src/project", "--cleanPersistedProgram"]
4847
},
4948
noChangeRun,
5049
{
@@ -55,10 +54,61 @@ namespace ts {
5554
],
5655
baselinePrograms: true,
5756
});
58-
}
5957

60-
describe("unittests:: tsbuild:: persistResolutions::", () => {
61-
verifyTscPersistsResolutions("--b");
62-
verifyTscPersistsResolutions("--b", "outFile.js");
58+
verifyTscSerializedIncrementalEdits({
59+
scenario: "persistResolutions",
60+
subScenario: `saves resolution and uses it for new program with outFile`,
61+
fs: () => loadProjectFromFiles({
62+
"/src/project/src/main.ts": Utils.dedent`
63+
import { something } from "./filePresent";
64+
import { something2 } from "./fileNotFound";`,
65+
"/src/project/src/filePresent.ts": `export function something() { return 10; }`,
66+
"/src/project/tsconfig.json": JSON.stringify({
67+
compilerOptions: {
68+
module: "amd",
69+
composite: true,
70+
persistResolutions: true,
71+
traceResolution: true,
72+
outFile: "outFile.js"
73+
},
74+
include: ["src/**/*.ts"]
75+
}),
76+
}),
77+
commandLineArgs: ["--b", "src/project"],
78+
incrementalScenarios: [
79+
noChangeRun,
80+
{
81+
subScenario: "Modify main file",
82+
buildKind: BuildKind.IncrementalDtsChange,
83+
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
84+
},
85+
{
86+
subScenario: "Add new module and update main file",
87+
buildKind: BuildKind.IncrementalDtsChange,
88+
modifyFs: fs => {
89+
fs.writeFileSync(`/src/project/src/newFile.ts`, "export function foo() { return 20; }");
90+
prependText(fs, `/src/project/src/main.ts`, `import { foo } from "./newFile";`);
91+
},
92+
},
93+
{
94+
subScenario: "Write file that could not be resolved",
95+
buildKind: BuildKind.IncrementalDtsChange,
96+
modifyFs: fs => fs.writeFileSync(`/src/project/src/fileNotFound.ts`, "export function something2() { return 20; }"),
97+
},
98+
{
99+
subScenario: "Clean resolutions",
100+
buildKind: BuildKind.IncrementalDtsChange,
101+
modifyFs: noop,
102+
commandLineArgs: ["--b", "src/project", "--cleanPersistedProgram"]
103+
},
104+
noChangeRun,
105+
{
106+
subScenario: "Modify main file",
107+
buildKind: BuildKind.IncrementalDtsChange,
108+
modifyFs: fs => appendText(fs, `/src/project/src/main.ts`, `something();`),
109+
},
110+
],
111+
baselinePrograms: true,
112+
});
63113
});
64114
}

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class someClass2 { }`),
530530
subScenario: "Clean resolutions",
531531
buildKind: BuildKind.IncrementalDtsChange,
532532
modifyFs: noop,
533-
commandLineArgs: ["--b", "/src/tests", "--cleanResolutions"],
533+
commandLineArgs: ["--b", "/src/tests", "--cleanPersistedProgram"],
534534
},
535535
{
536536
subScenario: "Modify core",

src/testRunner/unittests/tsbuild/watchMode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ const a: string = "hello";`),
11691169
sys.exit = noop;
11701170
fakes.withTemporaryPatchingForBuildinfoReadWrite(sys, sys => {
11711171
executeCommandLine(sys, noop, ["--b", "."]);
1172-
executeCommandLine(sys, noop, ["--b", ".", "--cleanResolutions"]);
1172+
executeCommandLine(sys, noop, ["--b", ".", "--cleanPersistedProgram"]);
11731173
});
11741174
sys.exit = exit;
11751175
sys.clearOutput();
@@ -1351,7 +1351,7 @@ const a: string = "hello";`),
13511351
sys.exit = noop;
13521352
fakes.withTemporaryPatchingForBuildinfoReadWrite(sys, sys => {
13531353
executeCommandLine(sys, noop, ["--b", "."]);
1354-
executeCommandLine(sys, noop, ["--b", ".", "--cleanResolutions"]);
1354+
executeCommandLine(sys, noop, ["--b", ".", "--cleanPersistedProgram"]);
13551355
});
13561356
sys.exit = exit;
13571357
sys.clearOutput();

0 commit comments

Comments
 (0)