Auto Import Not Working Properly

Hello!  I have a package (we'll call Package A) that consumes a single package (we'll call Package B), which has dependencies on several other packages (like Vue, TypeScript, etc.).  I'm essentially “extending” a package.json, but there's no real way to do this AFAIK.  Anyway, when I try to import something that's a dep in Package B, I don't get the ability to auto import/use intellisense.  I had the same issue in VSCode, but I was able to solve it by setting the property typescript.preferences.includePackageJsonAutoImports to “on”, per this answer.  Is there any such ability in WebStorm?

0

Would it be possible to narrow the problem down to a minimal repo project and share this with us in a new youtrack ticket?

0

I can try, but it's going to take a minute.  As far as you know, there's no such property that I can set in WebStorm?  It appears to be a typescript parser or language setting, per the TS 4.0 release notes, so I'm wondering if WebStorm exposes how I can modify that config value.  The weird thing is, after I add a package reference initially, the IDE remembers it, and I can import it just fine, but it's always the first time using something that needs to be imported.

0

As it's written in the release notes, the only editor that supports this mode is Visual Studio Code which has some UX improvements coming up in Visual Studio Code Insiders. There is no such option in WebStorm. But it normally does provide the auto-import from the modules listed in the package.json dependencies.

0

Elena Pogorelova, yeah, I think the issue is that Package B “extends” Package A only… no other deps, and the dependencies in Package A are not traversed, therefore I can't import from those dependencies through intellisense/auto completion.  I have created this ticket, as you've asked.

0

Thank you for sharing all the details! I have reproduced the issue. The problem is that auto-import, types resolving and other advanced functionality is based on indexing. To reduce the time required for creating the index and the overall performance, the node_modules folder is auto-excluded from indexing, but the direct dependencies listed in the package.json are included for completion/auto-import/etc. In case of extending the package, its dependencies are not explicitly included in current package dependencies, so the IDE doesn't include them in the project index. 

0

That's what I figured was happening.  Guess we'll see what Andrey comes up with, thanks for your help!

0

请先登录再写评论。