Auto Import child dependencies TypeScript

For my organization, we have one NPM dependency that contains many child dependencies that we use across all our projects. When I try and use an export from one of the child dependencies, I get an error saying it can't be found (which is expected), but both auto-import and intellisense don't recognize the child dependencies installed for the project and fail to suggest I import it. However, when I manually import the dependency, I get no errors from the IDE. Is there some setting in the IDE I'm missing or some export I'm missing from the parent dependency I'm including in the project that's preventing auto-import from finding the included exports?

Currently we're using the peerDependnecies section of package.json and were hoping for a cleaner solution.

4 comments
Comment actions Permalink

Auto-import/completion only work for those modules that are included in the project index. By default, only direct dependencies listed in dependencies, devDependencies and optionalDependencies sections of package.json are indexed, peerdependencies are ignored

0
Comment actions Permalink

OK. Is there any setting I can change to tell IntelliJ to index peerDependencies?

0
Comment actions Permalink

There are no settings for that; you can only un-exclude the corresponding packages manually using Mark Directory As > Not Excluded on a module folder

0
Comment actions Permalink

npm 7 installs peer-dependencies by default now (this behavior was removed in npm 4 onwards but now it's back, and it's working pretty well from my experience).

Lile Blake Morgan, we are in the same situation. We have a lot of apps all relying on common packages peer-dependencies. Not being able to auto-import / not having code-completing is really painful for us.

The workaround of marking the folder as "Not Excluded" is cumbersome and it has its own drawbacks, for example, when you search (Ctrl + Shift + F) it searches in those folders as well.

Are you planning to tackle this issue officially or it's going to stay like that?

0

Please sign in to leave a comment.