Skip to content

Commit 0716898

Browse files
committed
Add test where file from referenced project of solution belongs to inferred project instead of referenced project
1 parent 64f6c84 commit 0716898

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/testRunner/unittests/tsserver/projectReferences.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,5 +1839,61 @@ bar();
18391839
// No new solutions/projects loaded
18401840
checkNumberOfProjects(service, { configuredProjects: 1 });
18411841
});
1842+
1843+
it("when default project is solution project", () => {
1844+
const tsconfigSrc: File = {
1845+
path: `${tscWatch.projectRoot}/tsconfig-src.json`,
1846+
content: JSON.stringify({
1847+
compilerOptions: {
1848+
composite: true,
1849+
outDir: "./target/",
1850+
baseUrl: "./src/"
1851+
},
1852+
include: ["./src/**/*"]
1853+
})
1854+
};
1855+
const tsconfig: File = {
1856+
path: `${tscWatch.projectRoot}/tsconfig.json`,
1857+
content: JSON.stringify({
1858+
references: [{ path: "./tsconfig-src.json" }],
1859+
files: []
1860+
})
1861+
};
1862+
const main: File = {
1863+
path: `${tscWatch.projectRoot}/src/main.ts`,
1864+
content: `import { foo } from 'helpers/functions';
1865+
foo;`
1866+
};
1867+
const helper: File = {
1868+
path: `${tscWatch.projectRoot}/src/helpers/functions.ts`,
1869+
content: `export const foo = 1;`
1870+
};
1871+
const host = createServerHost([tsconfigSrc, tsconfig, main, helper, libFile]);
1872+
const session = createSession(host, { canUseEvents: true });
1873+
const service = session.getProjectService();
1874+
service.openClientFile(main.path);
1875+
checkNumberOfProjects(service, { configuredProjects: 1, inferredProjects: 1 });
1876+
checkProjectActualFiles(service.inferredProjects[0], [main.path, libFile.path]);
1877+
checkProjectActualFiles(service.configuredProjects.get(tsconfig.path)!, [tsconfig.path]);
1878+
1879+
const location = protocolTextSpanFromSubstring(main.content, `'helpers/functions'`);
1880+
verifyGetErrRequest({
1881+
session,
1882+
host,
1883+
expected: [
1884+
{
1885+
file: main,
1886+
syntax: [],
1887+
semantic: [createDiagnostic(
1888+
location.start,
1889+
location.end,
1890+
Diagnostics.Cannot_find_module_0,
1891+
["helpers/functions"]
1892+
)],
1893+
suggestion: []
1894+
},
1895+
]
1896+
});
1897+
});
18421898
});
18431899
}

0 commit comments

Comments
 (0)