Skip to content

Commit d3f954e

Browse files
committed
Add failing testcase where when d.ts file is in program, the files get emitted multiple times with --out setting
1 parent 89e19ff commit d3f954e

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎src/harness/unittests/tscWatchMode.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,46 @@ namespace ts.tscWatch {
11051105
const outJs = "/a/out.js";
11061106
createWatchForOut(/*out*/ undefined, outJs);
11071107
});
1108+
1109+
it("with --outFile and multiple declaration files in the program", () => {
1110+
const file1: FileOrFolder = {
1111+
path: "/a/b/output/AnotherDependency/file1.d.ts",
1112+
content: "declare namespace Common.SomeComponent.DynamicMenu { enum Z { Full = 0, Min = 1, Average = 2, } }"
1113+
};
1114+
const file2: FileOrFolder = {
1115+
path: "/a/b/dependencies/file2.d.ts",
1116+
content: "declare namespace Dependencies.SomeComponent { export class SomeClass { version: string; } }"
1117+
};
1118+
const file3: FileOrFolder = {
1119+
path: "/a/b/project/src/main.ts",
1120+
content: "namespace Main { export function fooBar() {} }"
1121+
};
1122+
const file4: FileOrFolder = {
1123+
path: "/a/b/project/src/main2.ts",
1124+
content: "namespace main.file4 { import DynamicMenu = Common.SomeComponent.DynamicMenu; export function foo(a: DynamicMenu.z) { } }"
1125+
};
1126+
const configFile: FileOrFolder = {
1127+
path: "/a/b/project/tsconfig.json",
1128+
content: JSON.stringify({
1129+
compilerOptions: {
1130+
outFile: "../output/common.js",
1131+
target: "es5"
1132+
},
1133+
files: [file1.path, file2.path, file3.path, file4.path]
1134+
})
1135+
};
1136+
const files = [file1, file2, file3, file4];
1137+
const allfiles = files.concat(configFile);
1138+
const host = createWatchedSystem(allfiles);
1139+
const originalWriteFile = host.writeFile.bind(host);
1140+
let numberOfTimesFileWritten = 0;
1141+
host.writeFile = (p: string, content: string) => {
1142+
numberOfTimesFileWritten++;
1143+
return originalWriteFile(p, content);
1144+
};
1145+
createWatchModeWithConfigFile(configFile.path, host);
1146+
assert.equal(numberOfTimesFileWritten, 1);
1147+
});
11081148
});
11091149

11101150
describe("tsc-watch emit for configured projects", () => {

0 commit comments

Comments
 (0)