Description
TypeScript Version: 3.7.2
Issue
I noticed that auto-import in VS Code stopped working for some of my projects after updating to TS 3.7 (everything worked in 3.6). After some digging I noticed that the Language Server logs included the line "forEachExternalModuleToImportFrom: filtered out XX modules by package.json contents
".
In short, any module that isn't directly included in package.json
seems to be no longer considered for auto-import by TS 3.7. This includes indirect dependencies: modules that are dependencies of modules that are in fact included in package.json
.
For example, module 'my-web-lib' that has a dependency on 'my-lib' is in my package.json; but if I don't also include 'my-lib' in my package.json explicitly, the Language Server will no longer consider auto-importing from 'my-lib'. This used to work fine, which I found useful for 'meta' packages that import a bunch of versioned dependencies in one go, or perhaps a combined node/web package that's imported indirectly using web-specific or node-specific packages without having to mention (and version) the final packages.
Now that I know what's going on, this seems like a trivial issue ('just add the indirect dependency to my package'). This is possibly a new feature in TS 3.7, but I can't find it in the change logs. Just in case this is an unintended side effect of some other change, I'll create this issue here. Also in case others are confused as well, this issue might help them figure out what's going on.
Code
This issue is related to NPM dependencies, so requires a bit of setup. Essentially, add a package.json dependency (or dev dependency) that itself has a dependency on a module that exports TypeScript types. Then try to import a symbol from the second-level dependency.
I have a few specific examples but since I'm updating my repos to eradicate this issue, I won't leave any links here for now; please let me know if you need me to set up a repo.
Expected behavior:
As above, auto-import like it used to work in 3.6.
Actual behavior:
As above, indirect dependencies are no longer considered for auto-import.
Search Terms: Auto-import indirect dependencies NPM modules d.ts