Angular 10 “No definition found for …” in HTML component in Visual Studio Code

3.6k Views Asked by At

I'm working with angular 10 in VSCode and everything was working fine until today. Suddenly I can't go to definition from HTML component neither via F12, right click - Go to definition nor Ctrl+click.

Go to definition works just on typescript components, also I don't get any errors except "No definition found for...."

I've tried updating VS Code, reinstalling VS Code and reinstalling extensions: Angular Essentials by John Papa Angular Language Service Angular Snippets

Also I experience the same behavior on all of my projects (two of them).

Thanks!

3

There are 3 best solutions below

2
LeonardoX On

In my case, after several tries, I found the cause was an *ngIf="whatever" in the parent DOM element and in some other cases in other elements in the same level, after removing this, all definitions were reachable again... this is a bug As a workaround, I downgraded Angular Language Service to 11.2.0

0
Jonathan Castro Hernandez On

work for me....

To enable the latest Language Service features, set the strictTemplates option in tsconfig.json by setting strictTemplates to true, as shown in the following example:

content_copy "angularCompilerOptions": { "strictTemplates": true }

https://angular.io/guide/language-service

1
Quentin Mayo On

Not sure if it helps anyone, but I found that I just needed to update to the latest Angular Language Service. I switch to using VS code preview and noticed a similar error compared to when I was using Webstorm.

After I installed the Angular Language Service package under VS extensions, it fixed this issue. https://marketplace.visualstudio.com/items?itemName=Angular.ng-template