angular / vscode-ng-language-service

Angular extension for Visual Studio Code
MIT License
781 stars 119 forks source link

'component' is not a known element #14

Closed fknop closed 7 years ago

fknop commented 7 years ago

When a custom component is imported via a module, it cannot be found inside a template, it shows:

image

chuckjaz commented 7 years ago

Can you produce a repository that duplicates this?

fknop commented 7 years ago

I'm not able to reproduce it in a new project, I'll come back to you if I succeed to reproduce it.

petebacondarwin commented 7 years ago

This may be related to #36?

chuckjaz commented 7 years ago

@petebacondarwin Could be but without a solid repo it is hard to be sure.

chuckjaz commented 7 years ago

Please reopen if you can still reproduce this in 0.1.0

alejandrocoding commented 7 years ago

I have the same error:

bug

It happens with those component you are importing by their modules, so in my ngModule I import XModule and I use XComponent inside of my new component and it triggers that error as it doesn't recognize that the component is coming from the imported module.

alejandrocoding commented 7 years ago

version 0.1.2

chuckjaz commented 7 years ago

@ialex90 Can you open a separate issue and attach either a .zip file that reproduces this or a github project I can clone?

alejandrocoding commented 7 years ago

@chuckjaz I've tried this plugin in 2 different environments with the same result. I think if you import a module and try to use the component, will see the error. Haven't this happened to you in the latest version? It's a very common scenario and I've faced on Windows & MacOS. Do you need me to recreate this scenario?

chuckjaz commented 7 years ago

This is not the same issue as above which is why I would like a new issue open. Second, I always want to be very clear about what issue is being resolved. Having a repro attached to the bug helps with that immensely event if you believe the repro is trivial, please attach one.

Also, note that structural changes (such as importing and modifying a module) take a few seconds to propagate because we are deferring some expensive calculations. Try modifying the source reporting the error a 5 to 10 seconds after you made the @NgModule change.

alejandrocoding commented 7 years ago

I have been creating a small project with a single ngmodule exported and imported and it works well with the plugin. I got the update today too, not sure if it's because of that, anyway, in the big project I'm working on, even with the newest version, it does trigger that error that I showed above and I can't replicate a scenario with 30-40 module just to see if triggers the error or not.

I will wait if someone else has the same error or maybe in a near future I won't see those errors and will be able to use the plugin.

uberspeck commented 7 years ago

I'm seeing this issue in v0.1.3. Everything works for me (compiles/runs etc), but my shared module components are still getting "not known element" errors. I've commented on #36

rweads0520 commented 6 years ago

Having this issue in 0.1.9. Only seems to be affecting library components referenced from outside of the app's project structure, even when both project folders are loaded into vs code. e.g. referencing from "projects/shared-lib/src/public_api" shows no error, referencing from "../ngls-issue-lib/projects/ext-lib/src/public_api" can't resolve the component and shows an error.

The app builds and runs without problems, displays all components.

Reproduced in sample project at public repo: https://github.com/rweads0520/ngls-issue.git

RajendrasinhParmar commented 6 years ago

I'm also having a same issue

htevfik commented 6 years ago

i'm also having this issue while using a third party module angular2gridster on my ionic4 project.

jiovanniro commented 6 years ago

Check to see if the component was imported and added to @NgModule declarations in your app.module.ts file. You may have to manually do the following:

  1. Import your component import { HomeComponent } from './home/home.component';

  2. add it to the @NgModule declarations @NgModule({ declarations: [ AppComponent, HomeComponent ]

a-eid commented 6 years ago

I'm still having this issue vscode version 1.27.2, I'd like to note that my app is working fine. and it's not a 3rd party component.

carlosearaujo commented 4 years ago

Add

schemas: [ CUSTOM_ELEMENTS_SCHEMA ]

on component module

kuncevic commented 4 years ago

Having that on mac Catalaina 10.15.2 with angular material components that I am exporting from the custom angular material module that lives in my shared library in my monorepo

VScode details: Version: 1.41.1 Commit: 26076a4de974ead31f97692a0d32f90d735645c0 Date: 2019-12-18T14:57:51.166Z Electron: 6.1.5 Chrome: 76.0.3809.146 Node.js: 12.4.0 V8: 7.6.303.31-electron.0 OS: Darwin x64 19.2.0

@carlosearaujo

Add

schemas: [ CUSTOM_ELEMENTS_SCHEMA ]

on component module

By adding schemas: [ CUSTOM_ELEMENTS_SCHEMA ] that to my material module didn't fix the problem.

UPDATE: Seems like there is an issue with language-service https://github.com/angular/vscode-ng-language-service/issues/340

angular-automatic-lock-bot[bot] commented 4 years ago

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.