1namespace ts.projectSystem { 2 describe("unittests:: tsserver:: autoDiscovery", () => { 3 it("does not depend on extension", () => { 4 const file1 = { 5 path: "/a/b/app.html", 6 content: "" 7 }; 8 const file2 = { 9 path: "/a/b/app.d.ts", 10 content: "" 11 }; 12 const host = createServerHost([file1, file2]); 13 const projectService = createProjectService(host); 14 projectService.openExternalProject({ 15 projectFileName: "/a/b/proj.csproj", 16 rootFiles: [toExternalFile(file2.path), { fileName: file1.path, hasMixedContent: true, scriptKind: ScriptKind.JS }], 17 options: {} 18 }); 19 projectService.checkNumberOfProjects({ externalProjects: 1 }); 20 const typeAcquisition = projectService.externalProjects[0].getTypeAcquisition(); 21 assert.isTrue(typeAcquisition.enable, "Typine acquisition should be enabled"); 22 }); 23 }); 24 25 describe("unittests:: tsserver:: prefer typings to js", () => { 26 it("during second resolution pass", () => { 27 const typingsCacheLocation = "/a/typings"; 28 const f1 = { 29 path: "/a/b/app.js", 30 content: "var x = require('bar')" 31 }; 32 const barjs = { 33 path: "/a/b/node_modules/bar/index.js", 34 content: "export let x = 1" 35 }; 36 const barTypings = { 37 path: `${typingsCacheLocation}/node_modules/@types/bar/index.d.ts`, 38 content: "export let y: number" 39 }; 40 const config = { 41 path: "/a/b/jsconfig.json", 42 content: JSON.stringify({ compilerOptions: { allowJs: true }, exclude: ["node_modules"] }) 43 }; 44 const host = createServerHost([f1, barjs, barTypings, config]); 45 const projectService = createProjectService(host, { typingsInstaller: new TestTypingsInstaller(typingsCacheLocation, /*throttleLimit*/ 5, host) }); 46 47 projectService.openClientFile(f1.path); 48 projectService.checkNumberOfProjects({ configuredProjects: 1 }); 49 checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, barTypings.path, config.path]); 50 }); 51 }); 52} 53