Skip to content
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

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

Closed
lukeurban opened this issue Jan 17, 2019 · 9 comments
Closed

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

lukeurban opened this issue Jan 17, 2019 · 9 comments
Assignees
Labels
Domain: Completion Lists Duplicate Working as Intended

Comments

@lukeurban
Copy link

@lukeurban lukeurban commented Jan 17, 2019

  • 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 mjbvz commented Jan 17, 2019

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

@Prestini
Copy link

@Prestini Prestini commented Jan 18, 2019

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

Same thing here on Insiders also

@saulgill
Copy link

@saulgill saulgill commented Jan 25, 2019

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 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 aleclarson commented Jan 29, 2019

This issue provides a repro: microsoft/vscode#67505

@RyanCavanaugh RyanCavanaugh added the Needs Investigation label Jan 30, 2019
@aleclarson
Copy link

@aleclarson aleclarson commented Jan 30, 2019

Probably related: #29039

@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Aug 23, 2019

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 label Sep 16, 2019
@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Oct 1, 2019

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 Working as Intended Domain: Completion Lists and removed Needs Investigation Needs More Info labels Oct 1, 2019
@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Oct 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Completion Lists Duplicate Working as Intended
Projects
None yet
Development

No branches or pull requests

8 participants