• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts.tscWatch {
2    describe("unittests:: tsbuild:: moduleResolution:: handles the modules and options from referenced project correctly", () => {
3        function sys(optionsToExtend?: CompilerOptions) {
4            return createWatchedSystem([
5                {
6                    path: `${projectRoot}/packages/pkg1/index.ts`,
7                    content: Utils.dedent`
8                    import type { TheNum } from 'pkg2'
9                    export const theNum: TheNum = 42;`
10                },
11                {
12                    path: `${projectRoot}/packages/pkg1/tsconfig.json`,
13                    content: JSON.stringify({
14                        compilerOptions: { outDir: "build", ...optionsToExtend },
15                        references: [{ path: "../pkg2" }]
16                    })
17                },
18                {
19                    path: `${projectRoot}/packages/pkg2/const.ts`,
20                    content: `export type TheNum = 42;`
21                },
22                {
23                    path: `${projectRoot}/packages/pkg2/index.ts`,
24                    content: `export type { TheNum } from 'const';`
25                },
26                {
27                    path: `${projectRoot}/packages/pkg2/tsconfig.json`,
28                    content: JSON.stringify({
29                        compilerOptions: {
30                            composite: true,
31                            outDir: "build",
32                            baseUrl: ".",
33                            ...optionsToExtend
34                        }
35                    })
36                },
37                {
38                    path: `${projectRoot}/packages/pkg2/package.json`,
39                    content: JSON.stringify({
40                        name: "pkg2",
41                        version: "1.0.0",
42                        main: "build/index.js",
43                    })
44                },
45                {
46                    path: `${projectRoot}/node_modules/pkg2`,
47                    symLink: `${projectRoot}/packages/pkg2`,
48                },
49                libFile
50            ], { currentDirectory: projectRoot });
51        }
52
53        verifyTscWatch({
54            scenario: "moduleResolution",
55            subScenario: `resolves specifier in output declaration file from referenced project correctly`,
56            sys,
57            commandLineArgs: ["-b", "packages/pkg1", "--verbose", "--traceResolution"],
58            changes: emptyArray
59        });
60
61        verifyTscWatch({
62            scenario: "moduleResolution",
63            subScenario: `resolves specifier in output declaration file from referenced project correctly with preserveSymlinks`,
64            sys: () => sys({ preserveSymlinks: true }),
65            commandLineArgs: ["-b", "packages/pkg1", "--verbose", "--traceResolution"],
66            changes: emptyArray
67        });
68    });
69}
70