re: How to make TS more intelligent? VIEW POST

re: I am not sure how to fix that, but for me it's working fine. See attached image.

Yep, that works for me too. What I was trying to say is that 3rd party libs (inside node_modules) are not cached or read eagerly, and until you don't import something from the library, you won't have intellisense for that.

I wanted to know if it was possible to tell vscode to load eagerly some libs (we have a few private packages we use in our apps).


The reason for not loading node modules eagerly:


This is an intentional performance/helpfulness trade-off.

We don't eagerly consume all .d.ts files from node_modules - doing so would be prohibitively expensive in a world where there are regularly possible thousands of definition files in node_modules.

When the Angular .d.ts file isn't consumed, we have no way of knowing that NgModule happens to come from @angular/core, thus can't suggest that auto-import.


Although, you can achieve it using the way mentioned here:

Auto complete not working for packages except those under @types folder #30474

EnixCoda avatar
EnixCoda commented on Jan 19, 2019
  • VSCode Version: 1.30.2
  • OS Version: macOS v10.13.6

Auto complete is one of my favorite features of VS code. But sometimes it doesn't provide what I need.

Steps to Reproduce:

  1. Create a project with create-react-app: npx create-react-app test-auto-complete --typescript
  2. Create a empty file src/test.tsx.
  3. Make sure auto complete works: type isvalid and get following suggestions image Then confirm: image
  4. Install a typed package from npm. (I made one - safe-touch
  5. See if auto complete works for the package(type safe and expect suggestion of safeTouch): image Negative :(
  6. There is a difference between the types file of safe-touch and react. Safe-touch's is directly under node_modules while react's is under node_modules/@types/. Then I tried to make a folder under @types for the package, simply cp -r node_modules/safe-touch node_modules/@types.
  7. See if auto complete works now: image It works! 🎉🎉

So it seems that VS code is not able to auto complete types of node_modules/[package] even if the package is correctly typed?

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

Amazing! I didn't knew that! Those are really helpfull links. Thank you @shhdharmen !

code of conduct - report abuse