1

Recently there was an upgrade in WebStorm (I think) and it changed how paths were imported in my files. Previously, if I typed @Component and allow WebStorm to automatically import the path, it would use this form:

import { Component } from @angular/core

But recently it has started pulling in the full paths instead:

import { Component } from '@angular/core/src/metadata/directives';

Is there a configuration change I can make to address this?

[EDIT] I discovered that if I copy and paste code into a file, it will import the dependencies properly. This feels like a bug that my particular configuration is revealing.

It appears that the only libraries that do this are Angular libraries, so I suspect the problem is with the Angular plugin. I have reached out to JetBrains and they have no answers.

3
  • Try selecting "Invalidate caches / Reset" from the file menu and clear your caches. Commented Aug 13, 2019 at 15:00
  • Thanks for the suggestion, I selected "Invalidate caches / Restart" and it didn't make a difference; I still get the whole path. Commented Aug 16, 2019 at 17:41
  • 1
    I have seen this happen to me for my own libraries when I use ng generate library. I follow the documentation guide, but WebStorm keeps importing the long form of the path for the library components. I'm wondering if this is a bug. Commented Aug 16, 2019 at 18:30

1 Answer 1

2

And like that, one day, I log back in to discover the bug has been fixed. This appears to have been a problem with the Angular Plugin as imports for other libraries worked properly. Things that I tried to fix this include:

  • Restart Webstorm/Whole OS (I come from the Windows world)
  • File > Invalidate Caches / Restart...
  • Nearly every configuration of import options.
  • Fix a broken Webpack.config (give a default entry point)
  • Reinstall the Angular Plugin
  • Delete all WebStorm Configuration, restart and rebuild configuration by hand.
  • File a bug report with JetBrains which resulted in the support staff saying "I don't know"

None of the above did anything. I would love if someone from JetBrains would help me understand how to better help them understand bugs I find.

This isn't exactly a fix for the bug, but if anyone else discovers this happening in their code, hopefully, this will help them debug.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.