-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Auto Import not working with node_modules #30033
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
Comments
I confirmed this with [email protected] There do not appear to be any errors in the ts server logs. Once you add any |
This is an intentional performance/helpfulness trade-off. We don't eagerly consume all When the Angular |
I have this issue as well, and I'm confused as to why it was closed without further discussion. Is there any workaround you can suggest? For example, I'm using the wonderful |
I literally explained why it works the way it does, then you commented, now I'm responding. Not sure how that's "without further discussion" ? 😕
It sounds like you're having a different issue. Once you have the first import, subsequent imports to the same library should be available for automatic importing. Can you (in a new report) outline the steps to reproduce the problem you're describing? |
I am experiencing the same problem as @christianbradley describes. Unfortunately I wasn't able to create a 100% reproduction case, so decided not to post it. |
@RyanCavanaugh - by "it was closed without further discussion" I'm just referring to the fact that the feature was set to "closed" - without further discussion. With a library like fp-ts - everything is pulled from import { Option, fromNullable } from 'fp-ts/lib/Option' It does look like once I import from that file, anything exported from that file seems to generally be available for auto-import. However, if I start typing out another export from that library, say, Oddly, some exports from other modules are suggested - I'm assuming this is because are referenced by If there was a way to inform the compiler to eager-load everything from a specific folder, module, etc, that would be wonderful. As a side question - was this always how the compiler worked? I feel like this has only happened recently, but I could be wrong. |
@RyanCavanaugh is it possible to read only those specified in package.json and go down transitively? |
+1 |
Just for clarity of record keeping, #36042 tracks the reconsideration of this issue. |
Non working auto import suggestions for packages in node_modules confirmed for me in react blank project ( Environment
TypeScript Version: 4.2.3 Variant 1 Type somewhere Variant 2 Type somewhere Variant 3 Type somewhere What about another IDE? I am frustrated when I see that behavior in VSCode. In WebStorm, for example, all variants works perfectly. |
@Toliak those don’t work because those modules aren’t referenced from the package root. When we see your package.json has |
Why there cant be node_modules+1 recursive lookup not node_modules+n recursive and this can be adjusted via config? So all node_modules root packages are available via auto suggest??? not only packages listed in package.json. This is really annoying. I mean: package.json:
so some_package and some_other_package now will be available for autocomplete, but not some_dependency? I think its very often to install some package which has dependencies which we will use in project but they cant be auto-suggested until added into root package.json but i dont want to specify them only for vscode autosuggest because its an approach to have package which installs needed deps in project. |
We're not super interested to spend complexity or performance budget here. There are many more impactful issues to address first. You can write an import, once, to get the module into your program, after which point auto-import will see them. |
Steps to Reproduce:
npm install
NgModule
import (the@NgModule
will be highlighted with an error)@NgModule
. Here expected behavior is that the light bulb would appear and suggest to add missing import. In reality nothing happens. I am still able to add import manually but it's impossible to use auto import feature for this. When entering import manually Intellisense works without any problems.This might seem like a minor problem but the example is just a small extract from a big project. It seems that VSCode (or TS server) is not checking for possible typings in
node_modules
. In the end we have to add imports manually everywhere which is very time consuming and simply kills productivity.Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: