Skip to content

Commit 42a589f

Browse files
committed
Deprecate prepend option on project reference
1 parent ecaf6d9 commit 42a589f

File tree

62 files changed

+927
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+927
-11
lines changed

src/compiler/program.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,15 +4302,38 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
43024302
if (options.out) {
43034303
createDeprecatedDiagnosticForOption(version, "out");
43044304
}
4305+
4306+
forEachProjectReference(projectReferences, resolvedProjectReferences, (_resolvedRef, parent, index) => {
4307+
const ref = (parent ? parent.commandLine.projectReferences : projectReferences)![index];
4308+
if (ref.prepend) {
4309+
createDeprecatedOptionForVersionDiagnostic(
4310+
version,
4311+
(message, arg0, arg1, arg2) => createDiagnosticForReference(parent?.sourceFile as JsonSourceFile | undefined, index, message, arg0, arg1, arg2),
4312+
"prepend",
4313+
);
4314+
}
4315+
});
43054316
}
43064317

43074318
function createDeprecatedDiagnosticForOption(version: string, name: string, value?: string) {
4319+
return createDeprecatedOptionForVersionDiagnostic(
4320+
version,
4321+
(message, arg0, arg1, arg2) => createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined, message, arg0, arg1, arg2),
4322+
name,
4323+
value,
4324+
);
4325+
}
4326+
4327+
function createDeprecatedOptionForVersionDiagnostic(
4328+
version: string,
4329+
createDiagnostic: (message: DiagnosticMessage, arg0: string, arg1?: string, arg2?: string) => void,
4330+
name: string,
4331+
value?: string) {
43084332
if (version === DeprecationVersion.v6_0) {
4309-
createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined, Diagnostics.Flag_0_is_deprecated_Please_remove_it_from_your_configuration, value || name);
4333+
createDiagnostic(Diagnostics.Flag_0_is_deprecated_Please_remove_it_from_your_configuration, value || name);
43104334
}
43114335
else {
4312-
createDiagnosticForOption(/*onKey*/ !value, name, /*option2*/ undefined,
4313-
Diagnostics.Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error, value || name, DeprecationVersion.v5_5, DeprecationVersion.v5_0);
4336+
createDiagnostic(Diagnostics.Flag_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_ignoreDeprecations_Colon_2_to_silence_this_error, value || name, DeprecationVersion.v5_5, DeprecationVersion.v5_0);
43144337
}
43154338
}
43164339

@@ -4548,14 +4571,14 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
45484571
createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
45494572
}
45504573

4551-
function createDiagnosticForReference(sourceFile: JsonSourceFile | undefined, index: number, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number) {
4574+
function createDiagnosticForReference(sourceFile: JsonSourceFile | undefined, index: number, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number) {
45524575
const referencesSyntax = firstDefined(getTsConfigPropArray(sourceFile || options.configFile, "references"),
45534576
property => isArrayLiteralExpression(property.initializer) ? property.initializer : undefined);
45544577
if (referencesSyntax && referencesSyntax.elements.length > index) {
4555-
programDiagnostics.add(createDiagnosticForNodeInSourceFile(sourceFile || options.configFile!, referencesSyntax.elements[index], message, arg0, arg1));
4578+
programDiagnostics.add(createDiagnosticForNodeInSourceFile(sourceFile || options.configFile!, referencesSyntax.elements[index], message, arg0, arg1, arg2));
45564579
}
45574580
else {
4558-
programDiagnostics.add(createCompilerDiagnostic(message, arg0, arg1));
4581+
programDiagnostics.add(createCompilerDiagnostic(message, arg0, arg1, arg2));
45594582
}
45604583
}
45614584

src/testRunner/unittests/tsbuild/amdModulesWithOut.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
5959
subScenario: "modules and globals mixed in amd",
6060
});
6161

62+
verifyOutFileScenario({
63+
subScenario: "prepend reports deprecation error",
64+
modifyFs: fs => replaceText(fs, "/src/app/tsconfig.json", `"ignoreDeprecations": "5.0"`, ""),
65+
});
66+
6267
// Prologues
6368
describe("Prologues", () => {
6469
verifyOutFileScenario({

src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
125125
{
126126
"extends": "../tsconfig.base.json",
127127
"compilerOptions": {
128+
"ignoreDeprecations":"5.0",
128129
"composite": true,
129130
"outFile": "sub-project.js",
130131
@@ -150,6 +151,7 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
150151
{
151152
"extends": "../tsconfig.base.json",
152153
"compilerOptions": {
154+
"ignoreDeprecations":"5.0",
153155
"composite": true,
154156
"outFile": "sub-project-2.js",
155157
@@ -162,6 +164,7 @@ describe("unittests:: tsbuild:: javascriptProjectEmit::", () => {
162164
"/src/tsconfig.json": Utils.dedent`
163165
{
164166
"compilerOptions": {
167+
"ignoreDeprecations":"5.0",
165168
"composite": true,
166169
"outFile": "src.js"
167170
},

src/testRunner/unittests/tsbuild/outFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ ${internal} enum internalEnum { a, b, c }`);
611611
}));
612612
fs.writeFileSync("/src/third/tsconfig.json", JSON.stringify({
613613
compilerOptions: {
614+
ignoreDeprecations: "5.0",
614615
composite: true,
615616
declaration: true,
616617
declarationMap: false,

src/testRunner/unittests/tsbuildWatch/programUpdates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class someClass2 { }`),
274274
const logicTsConfig: File = {
275275
path: logic[0].path,
276276
content: JSON.stringify({
277-
compilerOptions: { composite: true, declaration: true, outFile: "index.js" },
277+
compilerOptions: { ignoreDeprecations: "5.0", composite: true, declaration: true, outFile: "index.js" },
278278
references: [{ path: "../core", prepend: true }]
279279
})
280280
};

tests/baselines/reference/tsbuild/amdModulesWithOut/modules-and-globals-mixed-in-amd.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const myVar = 30;
2424
//// [/src/app/tsconfig.json]
2525
{
2626
"compilerOptions": {
27+
"ignoreDeprecations": "5.0",
2728
"target": "es5",
2829
"module": "amd",
2930
"composite": true,

tests/baselines/reference/tsbuild/amdModulesWithOut/multiple-emitHelpers-in-all-projects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ appfile4Spread(10, ...appfile4_ar);
2929
//// [/src/app/tsconfig.json]
3030
{
3131
"compilerOptions": {
32+
"ignoreDeprecations": "5.0",
3233
"target": "es5",
3334
"module": "amd",
3435
"composite": true,

tests/baselines/reference/tsbuild/amdModulesWithOut/multiple-prologues-in-all-projects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const myVar = 30;
2626
//// [/src/app/tsconfig.json]
2727
{
2828
"compilerOptions": {
29+
"ignoreDeprecations": "5.0",
2930
"target": "es5",
3031
"module": "amd",
3132
"composite": true,

0 commit comments

Comments
 (0)