1namespace ts.projectSystem { 2 describe("unittests:: tsserver:: languageService", () => { 3 it("should work correctly on case-sensitive file systems", () => { 4 const lib = { 5 path: "/a/Lib/lib.d.ts", 6 content: "let x: number" 7 }; 8 const f = { 9 path: "/a/b/app.ts", 10 content: "let x = 1;" 11 }; 12 const host = createServerHost([lib, f], { executingFilePath: "/a/Lib/tsc.js", useCaseSensitiveFileNames: true }); 13 const projectService = createProjectService(host); 14 projectService.openClientFile(f.path); 15 projectService.checkNumberOfProjects({ inferredProjects: 1 }); 16 projectService.inferredProjects[0].getLanguageService().getProgram(); 17 }); 18 19 it("should support multiple projects with the same file under differing `paths` settings", () => { 20 const files = [ 21 { 22 path: "/project/shared.ts", 23 content: Utils.dedent` 24 import {foo_a} from "foo"; 25 ` 26 }, 27 { 28 path: `/project/a/tsconfig.json`, 29 content: `{ "compilerOptions": { "paths": { "foo": ["./foo.d.ts"] } }, "files": ["./index.ts", "./foo.d.ts"] }` 30 }, 31 { 32 path: `/project/a/foo.d.ts`, 33 content: Utils.dedent` 34 export const foo_a = 1; 35 ` 36 }, 37 { 38 path: "/project/a/index.ts", 39 content: `import "../shared";` 40 }, 41 { 42 path: `/project/b/tsconfig.json`, 43 content: `{ "compilerOptions": { "paths": { "foo": ["./foo.d.ts"] } }, "files": ["./index.ts", "./foo.d.ts"] }` 44 }, 45 { 46 path: `/project/b/foo.d.ts`, 47 content: Utils.dedent` 48 export const foo_b = 1; 49 ` 50 }, 51 { 52 path: "/project/b/index.ts", 53 content: `import "../shared";` 54 } 55 ]; 56 57 const host = createServerHost(files, { executingFilePath: "/project/tsc.js", useCaseSensitiveFileNames: true }); 58 const projectService = createProjectService(host); 59 projectService.openClientFile(files[3].path); 60 projectService.openClientFile(files[6].path); 61 projectService.checkNumberOfProjects({ configuredProjects: 2 }); 62 const proj1Diags = projectService.configuredProjects.get(files[1].path)!.getLanguageService().getProgram()!.getSemanticDiagnostics(); 63 Debug.assertEqual(proj1Diags.length, 0); 64 const proj2Diags = projectService.configuredProjects.get(files[4].path)!.getLanguageService().getProgram()!.getSemanticDiagnostics(); 65 Debug.assertEqual(proj2Diags.length, 1); 66 }); 67 }); 68} 69