Skip to content

Commit ebf323e

Browse files
authored
Merge pull request microsoft#32124 from austincummings/affectsEmitToModuleAndEsModuleInterop
Add affectsEmit to module and esModuleInterop options
2 parents 1bd631e + c30054d commit ebf323e

File tree

6 files changed

+552
-1
lines changed

6 files changed

+552
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ namespace ts {
245245
esnext: ModuleKind.ESNext
246246
}),
247247
affectsModuleResolution: true,
248+
affectsEmit: true,
248249
paramType: Diagnostics.KIND,
249250
showInSimplifiedHelpView: true,
250251
category: Diagnostics.Basic_Options,
@@ -590,6 +591,7 @@ namespace ts {
590591
name: "esModuleInterop",
591592
type: "boolean",
592593
affectsSemanticDiagnostics: true,
594+
affectsEmit: true,
593595
showInSimplifiedHelpView: true,
594596
category: Diagnostics.Module_Resolution_Options,
595597
description: Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ class someClass { }`),
906906
"target": "esnext",
907907
}
908908
}`);
909-
},
909+
},
910910
expectedDiagnostics: [
911911
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
912912
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
@@ -931,6 +931,94 @@ class someClass { }`),
931931
baselineOnly: true,
932932
verifyDiagnostics: true
933933
});
934+
935+
verifyTsbuildOutput({
936+
scenario: "when module option changes",
937+
projFs: () => projFs,
938+
time,
939+
tick,
940+
proj: "sample1",
941+
rootNames: ["/src/core"],
942+
expectedMapFileNames: emptyArray,
943+
lastProjectOutputJs: "/src/core/index.js",
944+
initialBuild: {
945+
modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{
946+
"compilerOptions": {
947+
"incremental": true,
948+
"module": "commonjs"
949+
}
950+
}`),
951+
expectedDiagnostics: [
952+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
953+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
954+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
955+
]
956+
},
957+
incrementalDtsChangedBuild: {
958+
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`),
959+
expectedDiagnostics: [
960+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
961+
[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"],
962+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
963+
]
964+
},
965+
outputFiles: [
966+
"/src/core/anotherModule.js",
967+
"/src/core/index.js",
968+
"/src/core/tsconfig.tsbuildinfo",
969+
],
970+
baselineOnly: true,
971+
verifyDiagnostics: true
972+
});
973+
974+
verifyTsbuildOutput({
975+
scenario: "when esModuleInterop option changes",
976+
projFs: () => projFs,
977+
time,
978+
tick,
979+
proj: "sample1",
980+
rootNames: ["/src/tests"],
981+
expectedMapFileNames: emptyArray,
982+
lastProjectOutputJs: "/src/tests/index.js",
983+
initialBuild: {
984+
modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{
985+
"references": [
986+
{ "path": "../core" },
987+
{ "path": "../logic" }
988+
],
989+
"files": ["index.ts"],
990+
"compilerOptions": {
991+
"composite": true,
992+
"declaration": true,
993+
"forceConsistentCasingInFileNames": true,
994+
"skipDefaultLibCheck": true,
995+
"esModuleInterop": false
996+
}
997+
}`),
998+
expectedDiagnostics: [
999+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
1000+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
1001+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
1002+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"],
1003+
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
1004+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
1005+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
1006+
]
1007+
},
1008+
incrementalDtsChangedBuild: {
1009+
modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`),
1010+
expectedDiagnostics: [
1011+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
1012+
[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"],
1013+
[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"],
1014+
[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"],
1015+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
1016+
]
1017+
},
1018+
outputFiles: [],
1019+
baselineOnly: true,
1020+
verifyDiagnostics: true
1021+
});
9341022
});
9351023
});
9361024
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//// [/src/tests/index.js]
2+
"use strict";
3+
var __importStar = (this && this.__importStar) || function (mod) {
4+
if (mod && mod.__esModule) return mod;
5+
var result = {};
6+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
7+
result["default"] = mod;
8+
return result;
9+
};
10+
exports.__esModule = true;
11+
var c = __importStar(require("../core/index"));
12+
var logic = __importStar(require("../logic/index"));
13+
c.leftPad("", 10);
14+
logic.getSecondsInDay();
15+
var mod = __importStar(require("../core/anotherModule"));
16+
exports.m = mod;
17+
18+
19+
//// [/src/tests/tsconfig.json]
20+
{
21+
"references": [
22+
{ "path": "../core" },
23+
{ "path": "../logic" }
24+
],
25+
"files": ["index.ts"],
26+
"compilerOptions": {
27+
"composite": true,
28+
"declaration": true,
29+
"forceConsistentCasingInFileNames": true,
30+
"skipDefaultLibCheck": true,
31+
"esModuleInterop": true
32+
}
33+
}
34+
35+
//// [/src/tests/tsconfig.tsbuildinfo]
36+
{
37+
"program": {
38+
"fileInfos": {
39+
"../../lib/lib.d.ts": {
40+
"version": "-15964756381",
41+
"signature": "-15964756381"
42+
},
43+
"../core/index.ts": {
44+
"version": "-13851440507",
45+
"signature": "-13851440507"
46+
},
47+
"../core/anothermodule.ts": {
48+
"version": "7652028357",
49+
"signature": "7652028357"
50+
},
51+
"../logic/index.ts": {
52+
"version": "-6548680073",
53+
"signature": "-6548680073"
54+
},
55+
"./index.ts": {
56+
"version": "12336236525",
57+
"signature": "-9209611"
58+
}
59+
},
60+
"options": {
61+
"composite": true,
62+
"declaration": true,
63+
"forceConsistentCasingInFileNames": true,
64+
"skipDefaultLibCheck": true,
65+
"esModuleInterop": true,
66+
"configFilePath": "./tsconfig.json"
67+
},
68+
"referencedMap": {
69+
"../logic/index.ts": [
70+
"../core/anothermodule.d.ts"
71+
],
72+
"./index.ts": [
73+
"../core/anothermodule.d.ts",
74+
"../core/index.d.ts",
75+
"../logic/index.d.ts"
76+
]
77+
},
78+
"exportedModulesMap": {
79+
"../logic/index.ts": [
80+
"../core/anothermodule.d.ts"
81+
],
82+
"./index.ts": [
83+
"../core/anothermodule.d.ts"
84+
]
85+
},
86+
"semanticDiagnosticsPerFile": [
87+
"../../lib/lib.d.ts",
88+
"../core/anothermodule.ts",
89+
"../core/index.ts",
90+
"../logic/index.ts",
91+
"./index.ts"
92+
]
93+
},
94+
"version": "FakeTSVersion"
95+
}
96+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//// [/src/core/anotherModule.js]
2+
define(["require", "exports"], function (require, exports) {
3+
"use strict";
4+
exports.__esModule = true;
5+
exports.World = "hello";
6+
});
7+
8+
9+
//// [/src/core/index.js]
10+
define(["require", "exports"], function (require, exports) {
11+
"use strict";
12+
exports.__esModule = true;
13+
exports.someString = "HELLO WORLD";
14+
function leftPad(s, n) { return s + n; }
15+
exports.leftPad = leftPad;
16+
function multiply(a, b) { return a * b; }
17+
exports.multiply = multiply;
18+
});
19+
20+
21+
//// [/src/core/tsconfig.json]
22+
{
23+
"compilerOptions": {
24+
"incremental": true,
25+
"module": "amd"
26+
}
27+
}
28+
29+
//// [/src/core/tsconfig.tsbuildinfo]
30+
{
31+
"program": {
32+
"fileInfos": {
33+
"../../lib/lib.d.ts": {
34+
"version": "-15964756381",
35+
"signature": "-15964756381"
36+
},
37+
"./anothermodule.ts": {
38+
"version": "-2676574883",
39+
"signature": "-8396256275"
40+
},
41+
"./index.ts": {
42+
"version": "-18749805970",
43+
"signature": "1874987148"
44+
},
45+
"./some_decl.d.ts": {
46+
"version": "-9253692965",
47+
"signature": "-9253692965"
48+
}
49+
},
50+
"options": {
51+
"incremental": true,
52+
"module": 2,
53+
"configFilePath": "./tsconfig.json"
54+
},
55+
"referencedMap": {},
56+
"exportedModulesMap": {},
57+
"semanticDiagnosticsPerFile": [
58+
"../../lib/lib.d.ts",
59+
"./anothermodule.ts",
60+
"./index.ts",
61+
"./some_decl.d.ts"
62+
]
63+
},
64+
"version": "FakeTSVersion"
65+
}
66+

0 commit comments

Comments
 (0)