Angular modules, directives, services etc can't resolve, show unused and missing imports for external and library

Hi,

All of a sudden I'm running into a issue where Webstorm can't seem to resolve external and library modules. For instance, it shows all my methods in my services located in my library as unused.

12 comments
Comment actions Permalink

Most probably Angular support is not enabled. Are Angular directives, etc. recognized in HTML files? Please select your .html file in the Project tool window and hit F1 (View | Quick Documentation) - what docs are shows? Please attach a screenshot.

Your idea.log (Help | Show Log in ...) would be also helpful

0
Comment actions Permalink

It tells me it's an HTML (Angular HTML template)

I cannot upload a log here since it only accepts img extensions.

0
Comment actions Permalink

As it recognizes your HTML as Angular template, Angular support is on. So it must be a different problem.

Did you try invalidating caches (File > Invalidate caches, Invalidate and restart)?

 

0
Comment actions Permalink

At least a hundred times already :)

0
Comment actions Permalink

can you share a project that can be used to recreate the issue?

0
Comment actions Permalink

Sadly I cannot. I still have these issues though where Webstorm is unable to resolve my library.

0
Comment actions Permalink

If you can't share your actual code, try composing a sample project that shows up the issue

0
Comment actions Permalink

Here's a sample project: https://github.com/lwensveen/webstorm-angular-test

As you can see the tsconfig has a paths property, yet it's impossible to have the path resolve when you import

0
Comment actions Permalink

Do you mean errors in imports like

import { SwagComponent } from 'swag';

In your tsconfig.json, you have the following path mappings:

"paths": {
"swag": [
"dist/swag"
],
"swag/*": [
"dist/swag/*"
]
}

But there is no dist folder in your project, you have to build your library (ng build swag) to get it created. Once you do this, the error will go away:

 

0
Comment actions Permalink

I did that, I think the issue is that the dist folder is marked as excluded. Might have to remove that, will report later how it went.

0
Comment actions Permalink

Yes, it can be the issue - though the TypeScript language service can process excluded folders (and thus the import path is resolved in .ts file), types resolving in Angular templates is based on the index that the IDE builds, so the properties from excluded folders won't be recognized

0
Comment actions Permalink

Hi Elena,

That was the issue, it's solved now. Thanks for all the help.

1

Please sign in to leave a comment.