Skip to content

Can't use auto import when node_modules are named "node_modules" #29629

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
lukeurban opened this issue Jan 17, 2019 · 10 comments
Closed

Can't use auto import when node_modules are named "node_modules" #29629

lukeurban opened this issue Jan 17, 2019 · 10 comments
Assignees
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Duplicate An existing issue was already created Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@lukeurban
Copy link

  • VSCode Version: 1.30.2 (1.30.2)
  • OS Version: macOS Mojave 10.14.2

Steps to Reproduce:

  1. Create new angular project using CLI
  2. Install dependencies
  3. Try to import module (eg. HttpClientModule)

Then no auto import is available. BUT!! if I change name from node_modules/ to node_modules2/ then everything is fine. I've tried few "fixes" with no success.
Screens
screenshot 2019-01-17 at 11 50 46
screenshot 2019-01-17 at 11 50 07

Does this issue occur when all extensions are disabled?: Yes

@mjbvz
Copy link
Contributor

mjbvz commented Jan 17, 2019

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

@Prestini
Copy link

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

Same thing here on Insiders also

@saulgill
Copy link

I also have this issue. I can confirm that changing the name of "node_modules" to "node_modules2" fixes the issue. Is there another fix that does not require this change?

@mjbvz mjbvz transferred this issue from microsoft/vscode Jan 29, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Jan 29, 2019

I confirmed this using TS 3.3-rc and a new angular app created from the CLI.

HttpClientModule is defined in @angular/common/http. Manually adding this import works but I don't see where the http.d.ts typings are exported in the @angular/common package's main index.d.ts

@mjbvz mjbvz removed their assignment Jan 29, 2019
@aleclarson
Copy link

aleclarson commented Jan 29, 2019

This issue provides a repro: microsoft/vscode#67505

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jan 30, 2019
@aleclarson
Copy link

Probably related: #29039

@andrewbranch
Copy link
Member

The reason renaming the node_modules folder works is that the default value of exclude in tsconfig.json includes "node_modules". The practical effect of this is that TypeScript doesn’t know about anything inside node_modules until you import something in there—this is by design. (See #28773.)

It’s possible that’s what’s happening, but there’s not enough information here to know for sure yet. To test that theory, can you try adding an import "@angular/common/http"; anywhere in your project? If, after that, auto-import for HttpClientModule works, then this is working as intended. If it doesn’t, then this is a bug.

@andrewbranch andrewbranch added the Needs More Info The issue still hasn't been fully clarified label Sep 16, 2019
@andrewbranch
Copy link
Member

To test that theory, can you try adding an import "@angular/common/http"; anywhere in your project? If, after that, auto-import for HttpClientModule works, then this is working as intended. If it doesn’t, then this is a bug.

I just did this myself, and the auto-import for HttpClientModule shows up, which makes this expected behavior, and a duplicate of #30033 and #28773.

I will note, though, that despite our current stance that this is a “working as intended,” we are paying attention to the fact that users are frequently confused by this behavior and/or request that the behavior change, and I’m brainstorming ways to make the experience better. Just can’t promise anything specific yet.

@andrewbranch andrewbranch added Duplicate An existing issue was already created Working as Intended The behavior described is the intended behavior; this is not a bug Domain: Completion Lists The issue relates to showing completion lists in an editor and removed Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified labels Oct 1, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@Vinn55
Copy link

Vinn55 commented Sep 17, 2022

I have the same issue with HttpClientModule. Just see no suggestion. #29629 (comment)
adding an import "@angular/common/http"; anywhere in my project, after that, auto-import for HttpClientModule works. I can't find what need to do. For diff IDE only in VScode, we have this problem (auto-import suggestion, webstorm runs file indexation and maybe need update this process in VScode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Duplicate An existing issue was already created Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

9 participants