简体   繁体   中英

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

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!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM