Skip to content

Commit c30054d

Browse files
Fix esModuleInterop affectsEmit change test
1 parent 5b694f8 commit c30054d

File tree

3 files changed

+187
-64
lines changed

3 files changed

+187
-64
lines changed

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -982,34 +982,40 @@ class someClass { }`),
982982
lastProjectOutputJs: "/src/tests/index.js",
983983
initialBuild: {
984984
modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{
985+
"references": [
986+
{ "path": "../core" },
987+
{ "path": "../logic" }
988+
],
989+
"files": ["index.ts"],
985990
"compilerOptions": {
986-
"incremental": true,
987-
"module": "commonjs",
991+
"composite": true,
992+
"declaration": true,
993+
"forceConsistentCasingInFileNames": true,
994+
"skipDefaultLibCheck": true,
988995
"esModuleInterop": false
989996
}
990997
}`),
991998
expectedDiagnostics: [
992-
getExpectedDiagnosticForProjectsInBuild("src/tests/tsconfig.json"),
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"],
9931004
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
994-
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
1005+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
9951006
]
9961007
},
9971008
incrementalDtsChangedBuild: {
9981009
modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`),
9991010
expectedDiagnostics: [
1000-
getExpectedDiagnosticForProjectsInBuild("src/tests/tsconfig.json"),
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"],
10011014
[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"],
10021015
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
10031016
]
10041017
},
1005-
outputFiles: [
1006-
"/src/core/anotherModule.js",
1007-
"/src/core/index.js",
1008-
"/src/logic/index.js",
1009-
"/src/tests/index.js",
1010-
"/src/tests/tsconfig.json",
1011-
"/src/tests/tsconfig.tsbuildinfo"
1012-
],
1018+
outputFiles: [],
10131019
baselineOnly: true,
10141020
verifyDiagnostics: true
10151021
});

tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
//// [/src/logic/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-
function getSecondsInDay() {
13-
return c.multiply(10, 15);
14-
}
15-
exports.getSecondsInDay = getSecondsInDay;
16-
var mod = __importStar(require("../core/anotherModule"));
17-
exports.m = mod;
18-
19-
201
//// [/src/tests/index.js]
212
"use strict";
223
var __importStar = (this && this.__importStar) || function (mod) {
@@ -37,9 +18,16 @@ exports.m = mod;
3718

3819
//// [/src/tests/tsconfig.json]
3920
{
21+
"references": [
22+
{ "path": "../core" },
23+
{ "path": "../logic" }
24+
],
25+
"files": ["index.ts"],
4026
"compilerOptions": {
41-
"incremental": true,
42-
"module": "commonjs",
27+
"composite": true,
28+
"declaration": true,
29+
"forceConsistentCasingInFileNames": true,
30+
"skipDefaultLibCheck": true,
4331
"esModuleInterop": true
4432
}
4533
}
@@ -53,15 +41,15 @@ exports.m = mod;
5341
"signature": "-15964756381"
5442
},
5543
"../core/index.ts": {
56-
"version": "-18749805970",
57-
"signature": "1874987148"
44+
"version": "-13851440507",
45+
"signature": "-13851440507"
5846
},
5947
"../core/anothermodule.ts": {
60-
"version": "-2676574883",
61-
"signature": "-8396256275"
48+
"version": "7652028357",
49+
"signature": "7652028357"
6250
},
6351
"../logic/index.ts": {
64-
"version": "-5786964698",
52+
"version": "-6548680073",
6553
"signature": "-6548680073"
6654
},
6755
"./index.ts": {
@@ -70,28 +58,29 @@ exports.m = mod;
7058
}
7159
},
7260
"options": {
73-
"incremental": true,
74-
"module": 1,
61+
"composite": true,
62+
"declaration": true,
63+
"forceConsistentCasingInFileNames": true,
64+
"skipDefaultLibCheck": true,
7565
"esModuleInterop": true,
7666
"configFilePath": "./tsconfig.json"
7767
},
7868
"referencedMap": {
7969
"../logic/index.ts": [
80-
"../core/anothermodule.ts",
81-
"../core/index.ts"
70+
"../core/anothermodule.d.ts"
8271
],
8372
"./index.ts": [
84-
"../core/anothermodule.ts",
85-
"../core/index.ts",
86-
"../logic/index.ts"
73+
"../core/anothermodule.d.ts",
74+
"../core/index.d.ts",
75+
"../logic/index.d.ts"
8776
]
8877
},
8978
"exportedModulesMap": {
9079
"../logic/index.ts": [
91-
"../core/anothermodule.ts"
80+
"../core/anothermodule.d.ts"
9281
],
9382
"./index.ts": [
94-
"../core/anothermodule.ts"
83+
"../core/anothermodule.d.ts"
9584
]
9685
},
9786
"semanticDiagnosticsPerFile": [

tests/baselines/reference/tsbuild/sample1/initial-Build/when-esModuleInterop-option-changes.js

Lines changed: 144 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
//// [/src/core/anotherModule.d.ts]
2+
export declare const World = "hello";
3+
//# sourceMappingURL=anotherModule.d.ts.map
4+
5+
//// [/src/core/anotherModule.d.ts.map]
6+
{"version":3,"file":"anotherModule.d.ts","sourceRoot":"","sources":["anotherModule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAC"}
7+
18
//// [/src/core/anotherModule.js]
29
"use strict";
310
exports.__esModule = true;
411
exports.World = "hello";
512

613

14+
//// [/src/core/index.d.ts]
15+
export declare const someString: string;
16+
export declare function leftPad(s: string, n: number): string;
17+
export declare function multiply(a: number, b: number): number;
18+
//# sourceMappingURL=index.d.ts.map
19+
20+
//// [/src/core/index.d.ts.map]
21+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,EAAE,MAAsB,CAAC;AAChD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAAmB;AAC/D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAAmB"}
22+
723
//// [/src/core/index.js]
824
"use strict";
925
exports.__esModule = true;
@@ -14,6 +30,52 @@ function multiply(a, b) { return a * b; }
1430
exports.multiply = multiply;
1531

1632

33+
//// [/src/core/tsconfig.tsbuildinfo]
34+
{
35+
"program": {
36+
"fileInfos": {
37+
"../../lib/lib.d.ts": {
38+
"version": "-15964756381",
39+
"signature": "-15964756381"
40+
},
41+
"./anothermodule.ts": {
42+
"version": "-2676574883",
43+
"signature": "25219880154"
44+
},
45+
"./index.ts": {
46+
"version": "-18749805970",
47+
"signature": "11051732871"
48+
},
49+
"./some_decl.d.ts": {
50+
"version": "-9253692965",
51+
"signature": "-9253692965"
52+
}
53+
},
54+
"options": {
55+
"composite": true,
56+
"declaration": true,
57+
"declarationMap": true,
58+
"skipDefaultLibCheck": true,
59+
"configFilePath": "./tsconfig.json"
60+
},
61+
"referencedMap": {},
62+
"exportedModulesMap": {},
63+
"semanticDiagnosticsPerFile": [
64+
"../../lib/lib.d.ts",
65+
"./anothermodule.ts",
66+
"./index.ts",
67+
"./some_decl.d.ts"
68+
]
69+
},
70+
"version": "FakeTSVersion"
71+
}
72+
73+
//// [/src/logic/index.d.ts]
74+
export declare function getSecondsInDay(): number;
75+
import * as mod from '../core/anotherModule';
76+
export declare const m: typeof mod;
77+
78+
1779
//// [/src/logic/index.js]
1880
"use strict";
1981
exports.__esModule = true;
@@ -24,6 +86,64 @@ function getSecondsInDay() {
2486
exports.getSecondsInDay = getSecondsInDay;
2587
var mod = require("../core/anotherModule");
2688
exports.m = mod;
89+
//# sourceMappingURL=index.js.map
90+
91+
//// [/src/logic/index.js.map]
92+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,iCAAmC;AACnC,SAAgB,eAAe;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAFD,0CAEC;AACD,2CAA6C;AAChC,QAAA,CAAC,GAAG,GAAG,CAAC"}
93+
94+
//// [/src/logic/tsconfig.tsbuildinfo]
95+
{
96+
"program": {
97+
"fileInfos": {
98+
"../../lib/lib.d.ts": {
99+
"version": "-15964756381",
100+
"signature": "-15964756381"
101+
},
102+
"../core/index.ts": {
103+
"version": "-13851440507",
104+
"signature": "-13851440507"
105+
},
106+
"../core/anothermodule.ts": {
107+
"version": "7652028357",
108+
"signature": "7652028357"
109+
},
110+
"./index.ts": {
111+
"version": "-5786964698",
112+
"signature": "-6548680073"
113+
}
114+
},
115+
"options": {
116+
"composite": true,
117+
"declaration": true,
118+
"sourceMap": true,
119+
"forceConsistentCasingInFileNames": true,
120+
"skipDefaultLibCheck": true,
121+
"configFilePath": "./tsconfig.json"
122+
},
123+
"referencedMap": {
124+
"./index.ts": [
125+
"../core/anothermodule.d.ts",
126+
"../core/index.d.ts"
127+
]
128+
},
129+
"exportedModulesMap": {
130+
"./index.ts": [
131+
"../core/anothermodule.d.ts"
132+
]
133+
},
134+
"semanticDiagnosticsPerFile": [
135+
"../../lib/lib.d.ts",
136+
"../core/anothermodule.ts",
137+
"../core/index.ts",
138+
"./index.ts"
139+
]
140+
},
141+
"version": "FakeTSVersion"
142+
}
143+
144+
//// [/src/tests/index.d.ts]
145+
import * as mod from '../core/anotherModule';
146+
export declare const m: typeof mod;
27147

28148

29149
//// [/src/tests/index.js]
@@ -39,9 +159,16 @@ exports.m = mod;
39159

40160
//// [/src/tests/tsconfig.json]
41161
{
162+
"references": [
163+
{ "path": "../core" },
164+
{ "path": "../logic" }
165+
],
166+
"files": ["index.ts"],
42167
"compilerOptions": {
43-
"incremental": true,
44-
"module": "commonjs",
168+
"composite": true,
169+
"declaration": true,
170+
"forceConsistentCasingInFileNames": true,
171+
"skipDefaultLibCheck": true,
45172
"esModuleInterop": false
46173
}
47174
}
@@ -55,15 +182,15 @@ exports.m = mod;
55182
"signature": "-15964756381"
56183
},
57184
"../core/index.ts": {
58-
"version": "-18749805970",
59-
"signature": "1874987148"
185+
"version": "-13851440507",
186+
"signature": "-13851440507"
60187
},
61188
"../core/anothermodule.ts": {
62-
"version": "-2676574883",
63-
"signature": "-8396256275"
189+
"version": "7652028357",
190+
"signature": "7652028357"
64191
},
65192
"../logic/index.ts": {
66-
"version": "-5786964698",
193+
"version": "-6548680073",
67194
"signature": "-6548680073"
68195
},
69196
"./index.ts": {
@@ -72,28 +199,29 @@ exports.m = mod;
72199
}
73200
},
74201
"options": {
75-
"incremental": true,
76-
"module": 1,
202+
"composite": true,
203+
"declaration": true,
204+
"forceConsistentCasingInFileNames": true,
205+
"skipDefaultLibCheck": true,
77206
"esModuleInterop": false,
78207
"configFilePath": "./tsconfig.json"
79208
},
80209
"referencedMap": {
81210
"../logic/index.ts": [
82-
"../core/anothermodule.ts",
83-
"../core/index.ts"
211+
"../core/anothermodule.d.ts"
84212
],
85213
"./index.ts": [
86-
"../core/anothermodule.ts",
87-
"../core/index.ts",
88-
"../logic/index.ts"
214+
"../core/anothermodule.d.ts",
215+
"../core/index.d.ts",
216+
"../logic/index.d.ts"
89217
]
90218
},
91219
"exportedModulesMap": {
92220
"../logic/index.ts": [
93-
"../core/anothermodule.ts"
221+
"../core/anothermodule.d.ts"
94222
],
95223
"./index.ts": [
96-
"../core/anothermodule.ts"
224+
"../core/anothermodule.d.ts"
97225
]
98226
},
99227
"semanticDiagnosticsPerFile": [

0 commit comments

Comments
 (0)