Skip to content

AutoImportProvider doesn’t work with pnpm unless there are project references #42094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewbranch opened this issue Dec 23, 2020 · 0 comments · Fixed by #43892
Closed

AutoImportProvider doesn’t work with pnpm unless there are project references #42094

andrewbranch opened this issue Dec 23, 2020 · 0 comments · Fixed by #43892
Assignees
Labels
Bug A bug in TypeScript Domain: Auto-import Fix Available A PR has been opened for this issue

Comments

@andrewbranch
Copy link
Member

Discovered while investigating #40584, but is not directly related, and a fix for this is irrelevant to that issue on the whole. Fourslash server test:

/// <reference path="../fourslash.ts" />

// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }

// @Filename: /package.json
//// { "dependencies": { "mobx": "*" } }

// @Filename: /node_modules/.pnpm/[email protected]/node_modules/mobx/package.json
//// { "types": "dist/mobx.d.ts" }

// @Filename: /node_modules/.pnpm/[email protected]/node_modules/mobx/dist/mobx.d.ts
//// export declare function autorun(): void;

// @Filename: /index.ts
//// autorun/**/

// @link: /node_modules/.pnpm/[email protected]/node_modules/mobx -> /node_modules/mobx

goTo.marker("");
verify.importFixAtPosition([`import { autorun } from "mobx";\r\n\r\nautorun`]);

The problem is that the pnpm symlink doesn’t make it into the symlink cache, which is coincidentally fixed if there are project references due to:

function handleDirectoryCouldBeSymlink(directory: string) {
if (!host.getResolvedProjectReferences()) return;

The proper fix would probably be to save an originalPath on ResolvedTypeReferenceDirective during module resolution, and then do something with it in AutoImportProviderHost.getRootFileNames().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Auto-import Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant