1namespace ts { 2 describe("unittests:: tsbuild - output file paths", () => { 3 const noChangeProject: TestTscEdit = { 4 modifyFs: noop, 5 subScenario: "Normal build without change, that does not block emit on error to show files that get emitted", 6 commandLineArgs: ["-p", "/src/tsconfig.json"], 7 }; 8 const edits: TestTscEdit[] = [ 9 noChangeRun, 10 noChangeProject, 11 ]; 12 13 function verify(input: Pick<VerifyTscWithEditsInput, "subScenario" | "fs" | "edits">, expectedOuptutNames: readonly string[]) { 14 verifyTscWithEdits({ 15 scenario: "outputPaths", 16 commandLineArgs: ["--b", "/src/tsconfig.json", "-v"], 17 ...input 18 }); 19 20 it("verify getOutputFileNames", () => { 21 const sys = new fakes.System(input.fs().makeReadonly(), { executingFilePath: "/lib/tsc" }) as TscCompileSystem; 22 23 assert.deepEqual( 24 getOutputFileNames( 25 parseConfigFileWithSystem("/src/tsconfig.json", {}, /*extendedConfigCache*/ undefined, {}, sys, noop)!, 26 "/src/src/index.ts", 27 /*ignoreCase*/ false 28 ), 29 expectedOuptutNames 30 ); 31 }); 32 } 33 34 verify({ 35 subScenario: "when rootDir is not specified", 36 fs: () => loadProjectFromFiles({ 37 "/src/src/index.ts": "export const x = 10;", 38 "/src/tsconfig.json": JSON.stringify({ 39 compilerOptions: { 40 outDir: "dist" 41 } 42 }) 43 }), 44 edits, 45 }, ["/src/dist/index.js"]); 46 47 verify({ 48 subScenario: "when rootDir is not specified and is composite", 49 fs: () => loadProjectFromFiles({ 50 "/src/src/index.ts": "export const x = 10;", 51 "/src/tsconfig.json": JSON.stringify({ 52 compilerOptions: { 53 outDir: "dist", 54 composite: true 55 } 56 }) 57 }), 58 edits, 59 }, ["/src/dist/src/index.js", "/src/dist/src/index.d.ts"]); 60 61 verify({ 62 subScenario: "when rootDir is specified", 63 fs: () => loadProjectFromFiles({ 64 "/src/src/index.ts": "export const x = 10;", 65 "/src/tsconfig.json": JSON.stringify({ 66 compilerOptions: { 67 outDir: "dist", 68 rootDir: "src" 69 } 70 }) 71 }), 72 edits, 73 }, ["/src/dist/index.js"]); 74 75 verify({ 76 subScenario: "when rootDir is specified but not all files belong to rootDir", 77 fs: () => loadProjectFromFiles({ 78 "/src/src/index.ts": "export const x = 10;", 79 "/src/types/type.ts": "export type t = string;", 80 "/src/tsconfig.json": JSON.stringify({ 81 compilerOptions: { 82 outDir: "dist", 83 rootDir: "src" 84 } 85 }) 86 }), 87 edits, 88 }, ["/src/dist/index.js"]); 89 90 verify({ 91 subScenario: "when rootDir is specified but not all files belong to rootDir and is composite", 92 fs: () => loadProjectFromFiles({ 93 "/src/src/index.ts": "export const x = 10;", 94 "/src/types/type.ts": "export type t = string;", 95 "/src/tsconfig.json": JSON.stringify({ 96 compilerOptions: { 97 outDir: "dist", 98 rootDir: "src", 99 composite: true 100 } 101 }) 102 }), 103 edits, 104 }, ["/src/dist/index.js", "/src/dist/index.d.ts"]); 105 }); 106} 107