Vscode-ng-language-service: Angular Language Service fails to find RouterModule if it's encapsulated in a separate module

Created on 22 Apr 2017  路  11Comments  路  Source: angular/vscode-ng-language-service

I'm new to Angular 2 and now learn Angular 2 by Tour of Heroes Angular guide. Following their example I encapsulated my routes config in another module:

app-routing.module.ts
image

And then imported it in my main module and registered in within imports section of @NgModule decorator:

app.module.ts
image

However, Angular Language Service fails to see that I actually imported routing in my app, so when I write code that uses routing I get the following errors:
app.component.html
image

dashboard.component.html
image

P.S. Please, also note that static routerLinking doesn't cause an error.
P.P.S. Compiled app works fine, it's not an Angular 2 error.
P.P.S. Disabling/uninstalling Angular Language Service extension makes these error disappear.

Please, fix this :)

bug

Most helpful comment

As I said in my previous comment, it is indeed a problem with modules exported from another module. All the modules exported by our SharedModule don't get picked up by the language service.

All 11 comments

Similar issue here actually. Components declared in imported modules don't seem to be picked up by the language service. @Verbon could you set up a small repo with all your code for @chuckjaz to take a look at?

@hccampos @chuckjaz
Yes, please, here's my test Tour of Heroes project - https://github.com/Verbon/TourOfHeroes.

I'm pretty sure it's more than just RouterModule issue - I have pipes and directives that are also not recognized by the language service when they are imported through another module.

Yes, I'm having the same issue as well.
I have a SharedModule which imports CommonModule, FormsModule, TranslateModule and export those as well. In another feature module, it gives me an error on html files but the application works just fine. If I move those import lines to that feature module, it doesn't complain.

As I said in my previous comment, it is indeed a problem with modules exported from another module. All the modules exported by our SharedModule don't get picked up by the language service.

@hccampos is absolutely right: no pipes/directives/components from other (imported) modules are picked up. @chuckjaz, I'm sure you're aware of this. Is this on your roadmap or are you aware of a workaround?

The linked example does not reproduce with 0.1.4. Is this still an issue? Does it reproduce after a "Reload Window"?

@chuckjaz It should be working now. I had a similar problem, and it got away when I updated to 0.1.4.

Closing for now then.

@chuckjaz I saw this issue was closed quite a while ago (and am unsure if that means I should be creating a new one) But with version: @angular/language-service 5.2.8 I'm experiencing the same issues as described above. Re-exported modules from a shared Module cause the language service to not recognize the bindings HTML component tags etc.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings