Vscode-ng-language-service: Component not included in a module warning for all components not in root AppModule

Created on 8 Dec 2016  路  30Comments  路  Source: angular/vscode-ng-language-service

Hi,

This is looking very promising, can't wait to use it!

I am however having trouble getting this to recognise components that are declared in feature modules (both lazy-loaded and not). All these components have the following warning (with red squiggles under the component decorator).

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

This means that in templates (the app.component.html template in the root module is the only one) in this module I can get completion etc. to work for directives that are in the same module and imported angular built-in directives. However directives from my own imported modules i get the following.

[Angular] 'app-nav' is not a known element: 1. If 'app-nav' is an Angular component, then verify that it is part of this module. 2. If 'app-nav' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
Have i missed something or is this maybe a bug?

I am very excited to use this. It will make my angular 2 coding experience so much better and hopefully save a lot of time, so thanks!

bug tracking in angular

Most helpful comment

I'm using Angular Language Service 0.1.3 and I'm still having this same issue.

All 30 comments

It could be a bug but I am not sure. Can you produce a repository that reproduces this issue?

This error is generated when you include a reference to a component that is not included in the the NgModule it is declared in or one of the NgModules that is imported by its module.

The language service scans the entire project (everything included by the tsconfig.json) for @NgModule declarations and creates a dependency graph between the components and the modules. The first error is generated for components that are not declared in a module and the second is for references to components not reachable from the module the component is in.

Just tried in a new angular-cli project but can't seem to be able to reproduce the issue. Not sure if it's a problem that only affects projects over a certain threshold size/module structure.

The project in which I discovered the issue has 12 modules in total:

  • a core module
  • a shared module
  • 4 feature modules (with some nesting)
  • 1 root app module
  • 5 routing modules (corresponding to the 4 feature modules and single root app module)

Will have a further look and play around when I get a chance to see if I can discover at what point this is reproduced.

I think this might be related to #36

I'm still having the same issue with the latest version.

I have managed to narrow down one scenario that causes the bug.
In a simple solution created with the latest angular-cli, I have the following structure

  • A root AppModule

    • An AppComponent

  • A CoreModule.

    • A NavComponent

    • A HomeComponent

    • An AuthService

When I include the AuthSevice in the CoreModule's providers array and import the CoreModule into the AppModule I get the following errors.
coremodule

navcomp
The same error occurs with the HomeComponent too.

appcomponent

If I comment out the AuthService from the providers array in the CoreModule the errors go away.
The app works fine though.

I've uploaded the example to this repository.

Hope this helps track down the problem.

Tracked as https://github.com/angular/angular/issues/14631.

This bug will be closed when the fix for the above lands and a new release of ngls.visx is produced that includes it.

This has been fixed in 0.1.0

Still have the same problem, version 0.1.3

Just installed 0.1.3 to check out this plugin. Getting the same error on a project that's working fine.

It's also identifying