Skip to content

Commit 7e135e7

Browse files
authored
Merge pull request microsoft#31165 from Microsoft/targetAffectsEmit
Target affects emit hence mark the option so that all files are reemitted when target changes
2 parents 7423c69 + fb21e70 commit 7e135e7

File tree

5 files changed

+212
-4
lines changed

5 files changed

+212
-4
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ namespace ts {
218218
}),
219219
affectsSourceFile: true,
220220
affectsModuleResolution: true,
221+
affectsEmit: true,
221222
paramType: Diagnostics.VERSION,
222223
showInSimplifiedHelpView: true,
223224
category: Diagnostics.Basic_Options,

src/testRunner/unittests/tsbuild/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace ts {
6262
}
6363
}
6464

65-
const libContent = `${TestFSWithWatch.libFile.content}
65+
export const libContent = `${TestFSWithWatch.libFile.content}
6666
interface ReadonlyArray<T> {}
6767
declare const console: { log(msg: any): void; };`;
6868

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ namespace ts {
279279
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
280280
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"],
281281
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
282-
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
283282
);
284283
});
285284

@@ -309,8 +308,7 @@ namespace ts {
309308
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"],
310309
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
311310
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.base.json"],
312-
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
313-
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
311+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
314312
);
315313
});
316314
});
@@ -761,6 +759,56 @@ class someClass { }`),
761759
baselineOnly: true,
762760
verifyDiagnostics: true
763761
});
762+
763+
verifyTsbuildOutput({
764+
scenario: "when target option changes",
765+
projFs: () => projFs,
766+
time,
767+
tick,
768+
proj: "sample1",
769+
rootNames: ["/src/core"],
770+
expectedMapFileNames: emptyArray,
771+
lastProjectOutputJs: "/src/core/index.js",
772+
initialBuild: {
773+
modifyFs: fs => {
774+
fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// <reference no-default-lib="true"/>
775+
/// <reference lib="esnext" />`);
776+
fs.writeFileSync("/lib/lib.esnext.d.ts", libContent);
777+
fs.writeFileSync("/lib/lib.d.ts", `/// <reference no-default-lib="true"/>
778+
/// <reference lib="esnext" />`);
779+
fs.writeFileSync("/src/core/tsconfig.json", `{
780+
"compilerOptions": {
781+
"incremental": true,
782+
"listFiles": true,
783+
"listEmittedFiles": true,
784+
"target": "esnext",
785+
}
786+
}`);
787+
},
788+
expectedDiagnostics: [
789+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
790+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
791+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
792+
]
793+
},
794+
incrementalDtsChangedBuild: {
795+
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"),
796+
expectedDiagnostics: [
797+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
798+
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"],
799+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
800+
]
801+
},
802+
outputFiles: [
803+
"/src/core/anotherModule.js",
804+
"/src/core/anotherModule.d.ts",
805+
"/src/core/index.js",
806+
"/src/core/index.d.ts",
807+
"/src/core/tsconfig.tsbuildinfo",
808+
],
809+
baselineOnly: true,
810+
verifyDiagnostics: true
811+
});
764812
});
765813
});
766814
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//// [/src/core/anotherModule.js]
2+
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
4+
exports.World = "hello";
5+
6+
7+
//// [/src/core/index.js]
8+
"use strict";
9+
Object.defineProperty(exports, "__esModule", { value: true });
10+
exports.someString = "HELLO WORLD";
11+
function leftPad(s, n) { return s + n; }
12+
exports.leftPad = leftPad;
13+
function multiply(a, b) { return a * b; }
14+
exports.multiply = multiply;
15+
16+
17+
//// [/src/core/tsconfig.json]
18+
{
19+
"compilerOptions": {
20+
"incremental": true,
21+
"listFiles": true,
22+
"listEmittedFiles": true,
23+
"target": "es5",
24+
}
25+
}
26+
27+
//// [/src/core/tsconfig.tsbuildinfo]
28+
{
29+
"program": {
30+
"fileInfos": {
31+
"/lib/lib.d.ts": {
32+
"version": "8926001564",
33+
"signature": "8926001564"
34+
},
35+
"/lib/lib.esnext.d.ts": {
36+
"version": "-15964756381",
37+
"signature": "-15964756381"
38+
},
39+
"/src/core/anothermodule.ts": {
40+
"version": "-2676574883",
41+
"signature": "-8396256275"
42+
},
43+
"/src/core/index.ts": {
44+
"version": "-18749805970",
45+
"signature": "1874987148"
46+
},
47+
"/src/core/some_decl.d.ts": {
48+
"version": "-9253692965",
49+
"signature": "-9253692965"
50+
}
51+
},
52+
"options": {
53+
"incremental": true,
54+
"listFiles": true,
55+
"listEmittedFiles": true,
56+
"target": 1,
57+
"configFilePath": "/src/core/tsconfig.json"
58+
},
59+
"referencedMap": {},
60+
"exportedModulesMap": {},
61+
"semanticDiagnosticsPerFile": [
62+
"/lib/lib.d.ts",
63+
"/lib/lib.esnext.d.ts",
64+
"/src/core/anothermodule.ts",
65+
"/src/core/index.ts",
66+
"/src/core/some_decl.d.ts"
67+
]
68+
},
69+
"version": "FakeTSVersion"
70+
}
71+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//// [/lib/lib.d.ts]
2+
/// <reference no-default-lib="true"/>
3+
/// <reference lib="esnext" />
4+
5+
//// [/lib/lib.esnext.d.ts]
6+
/// <reference no-default-lib="true"/>
7+
interface Boolean {}
8+
interface Function {}
9+
interface CallableFunction {}
10+
interface NewableFunction {}
11+
interface IArguments {}
12+
interface Number { toExponential: any; }
13+
interface Object {}
14+
interface RegExp {}
15+
interface String { charAt: any; }
16+
interface Array<T> {}
17+
interface ReadonlyArray<T> {}
18+
declare const console: { log(msg: any): void; };
19+
20+
//// [/lib/lib.esnext.full.d.ts]
21+
/// <reference no-default-lib="true"/>
22+
/// <reference lib="esnext" />
23+
24+
//// [/src/core/anotherModule.js]
25+
export const World = "hello";
26+
27+
28+
//// [/src/core/index.js]
29+
export const someString = "HELLO WORLD";
30+
export function leftPad(s, n) { return s + n; }
31+
export function multiply(a, b) { return a * b; }
32+
33+
34+
//// [/src/core/tsconfig.json]
35+
{
36+
"compilerOptions": {
37+
"incremental": true,
38+
"listFiles": true,
39+
"listEmittedFiles": true,
40+
"target": "esnext",
41+
}
42+
}
43+
44+
//// [/src/core/tsconfig.tsbuildinfo]
45+
{
46+
"program": {
47+
"fileInfos": {
48+
"/lib/lib.esnext.d.ts": {
49+
"version": "-15964756381",
50+
"signature": "-15964756381"
51+
},
52+
"/lib/lib.esnext.full.d.ts": {
53+
"version": "8926001564",
54+
"signature": "8926001564"
55+
},
56+
"/src/core/anothermodule.ts": {
57+
"version": "-2676574883",
58+
"signature": "-8396256275"
59+
},
60+
"/src/core/index.ts": {
61+
"version": "-18749805970",
62+
"signature": "1874987148"
63+
},
64+
"/src/core/some_decl.d.ts": {
65+
"version": "-9253692965",
66+
"signature": "-9253692965"
67+
}
68+
},
69+
"options": {
70+
"incremental": true,
71+
"listFiles": true,
72+
"listEmittedFiles": true,
73+
"target": 8,
74+
"configFilePath": "/src/core/tsconfig.json"
75+
},
76+
"referencedMap": {},
77+
"exportedModulesMap": {},
78+
"semanticDiagnosticsPerFile": [
79+
"/lib/lib.esnext.d.ts",
80+
"/lib/lib.esnext.full.d.ts",
81+
"/src/core/anothermodule.ts",
82+
"/src/core/index.ts",
83+
"/src/core/some_decl.d.ts"
84+
]
85+
},
86+
"version": "FakeTSVersion"
87+
}
88+

0 commit comments

Comments
 (0)