mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Include type reference directives in symlink cache, wait until program is present to create it (#44259)
* Fix discovery of more pnpm symlinks * Add some tests * Never show pnpm paths in auto imports, even if there’s no other path * Import statement completions can return none * Fix tests * Add failing test showing poor symlink cache reuse * Fix test, fails for right reasons now * Preserve cache built up during program creation, then fill in with program resolutions * Remove obsolete comment * Remove obsolete type assertion * Revert fully filtering out ignored paths
This commit is contained in:
@@ -213,6 +213,7 @@
|
||||
"unittests/tsserver/session.ts",
|
||||
"unittests/tsserver/skipLibCheck.ts",
|
||||
"unittests/tsserver/smartSelection.ts",
|
||||
"unittests/tsserver/symlinkCache.ts",
|
||||
"unittests/tsserver/symLinks.ts",
|
||||
"unittests/tsserver/syntacticServer.ts",
|
||||
"unittests/tsserver/syntaxOperations.ts",
|
||||
|
||||
80
src/testRunner/unittests/tsserver/symlinkCache.ts
Normal file
80
src/testRunner/unittests/tsserver/symlinkCache.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
namespace ts.projectSystem {
|
||||
const appTsconfigJson: File = {
|
||||
path: "/packages/app/tsconfig.json",
|
||||
content: `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"baseUrl": "."
|
||||
}
|
||||
"references": [{ "path": "../dep" }]
|
||||
}`
|
||||
};
|
||||
|
||||
const appSrcIndexTs: File = {
|
||||
path: "/packages/app/src/index.ts",
|
||||
content: `import "dep/does/not/exist";`
|
||||
};
|
||||
|
||||
const depPackageJson: File = {
|
||||
path: "/packages/dep/package.json",
|
||||
content: `{ "name": "dep", "main": "dist/index.js", "types": "dist/index.d.ts" }`
|
||||
};
|
||||
|
||||
const depTsconfigJson: File = {
|
||||
path: "/packages/dep/tsconfig.json",
|
||||
content: `
|
||||
{
|
||||
"compilerOptions": { "outDir": "dist", "rootDir": "src", "module": "commonjs" }
|
||||
}`
|
||||
};
|
||||
|
||||
const depSrcIndexTs: File = {
|
||||
path: "/packages/dep/src/index.ts",
|
||||
content: `
|
||||
import "./sub/folder";`
|
||||
};
|
||||
|
||||
const depSrcSubFolderIndexTs: File = {
|
||||
path: "/packages/dep/src/sub/folder/index.ts",
|
||||
content: `export const dep = 0;`
|
||||
};
|
||||
|
||||
const link: SymLink = {
|
||||
path: "/packages/app/node_modules/dep",
|
||||
symLink: "../../dep",
|
||||
};
|
||||
|
||||
describe("unittests:: tsserver:: symlinkCache", () => {
|
||||
it("contains symlinks discovered by project references resolution after program creation", () => {
|
||||
const { session, projectService } = setup();
|
||||
openFilesForSession([appSrcIndexTs], session);
|
||||
const project = projectService.configuredProjects.get(appTsconfigJson.path)!;
|
||||
assert.deepEqual(
|
||||
project.getSymlinkCache()?.getSymlinkedDirectories()?.get(link.path + "/" as Path),
|
||||
{ real: "/packages/dep/", realPath: "/packages/dep/" as Path }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function setup() {
|
||||
const host = createServerHost([
|
||||
appTsconfigJson,
|
||||
appSrcIndexTs,
|
||||
depPackageJson,
|
||||
depTsconfigJson,
|
||||
depSrcIndexTs,
|
||||
depSrcSubFolderIndexTs,
|
||||
link,
|
||||
]);
|
||||
const session = createSession(host);
|
||||
const projectService = session.getProjectService();
|
||||
return {
|
||||
host,
|
||||
projectService,
|
||||
session,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user