typescriptintellij-ideaauto-import

Why does auto-import of some packages not work?


Intellij auto-import does not work for some packages.
e.g. here is a simple example project on Github where the auto-import from the change-case package does not work:

enter image description here

  1. When I click CTRL+SPACE for a function that exists in the package, I see no suggestions
  2. When I manually add the import (e.g. uncomment this line), it compiles fine
  3. I noticed that the change-case package has type defs in the subdirs dist and dist.es2015
    I guess this is the reason: if so, how can we solve this?

Solution

  • Auto-import only works for packages added as direct dependencies. Adding "snake-case": "^3.0.3" to package.json should help:

    enter image description here