Angular: Component X is not included in a module and will not be available inside a template

Viewed 7623

In my Angular application, I have few components which are used while testing and not included in any module.

In WebStorm, it shows me a lint error saying Component is not included in any module, while I know that this is not included and that is the purpose.

Is there a way to disable only this lint error while keeping all others enabled?

Angular: Component 'ComponentName' is not included in a module and will not be available inside a template. Consider adding it to a NgModule declaration.

I saw this threat, where it was suggested to disable all Angular lint errors. However, i think it is not a good idea to do that just for one issue. I am looking for a way to only disable this one error.

5 Answers

Worked for me:

File -> Invalidate Caches / Restart -> Invalidate and restart

I use PHPStorm and found this problem also when using Angular 4. I fixed it by npm install @angular/language-service.

You can add the following comment above the class declaration and it will skip the check for that class:

// noinspection AngularMissingOrInvalidDeclarationInModule

You can also get the editor to add that comment for you by using the contextual menu you get when you hover over the error and going to 'Inspection options > Suppress for statement'

Related