• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts {
2    describe("unittests:: tsbuild:: when project reference is referenced transitively", () => {
3        let projFs: vfs.FileSystem;
4        before(() => {
5            projFs = loadProjectFromDisk("tests/projects/transitiveReferences");
6        });
7        after(() => {
8            projFs = undefined!; // Release the contents
9        });
10
11        function modifyFsBTsToNonRelativeImport(fs: vfs.FileSystem, moduleResolution: "node" | "classic") {
12            fs.writeFileSync("/src/b.ts", `import {A} from 'a';
13export const b = new A();`);
14            fs.writeFileSync("/src/tsconfig.b.json", JSON.stringify({
15                compilerOptions: {
16                    composite: true,
17                    moduleResolution
18                },
19                files: ["b.ts"],
20                references: [{ path: "tsconfig.a.json" }]
21            }));
22        }
23
24        verifyTsc({
25            scenario: "transitiveReferences",
26            subScenario: "builds correctly",
27            fs: () => projFs,
28            commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
29        });
30
31        verifyTsc({
32            scenario: "transitiveReferences",
33            subScenario: "builds correctly when the referenced project uses different module resolution",
34            fs: () => projFs,
35            commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
36            modifyFs: fs => modifyFsBTsToNonRelativeImport(fs, "classic"),
37        });
38
39        verifyTsc({
40            scenario: "transitiveReferences",
41            subScenario: "reports error about module not found with node resolution with external module name",
42            fs: () => projFs,
43            commandLineArgs: ["--b", "/src/tsconfig.c.json", "--listFiles"],
44            modifyFs: fs => modifyFsBTsToNonRelativeImport(fs, "node"),
45        });
46    });
47}
48