[英]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.我正在使用 VSCode 中的 angular 10 ,直到今天一切正常。 Suddenly I can't go to definition from HTML component neither via F12, right click - Go to definition nor Ctrl+click.
突然,我无法通过 F12 从 HTML 组件定义 go 定义,也不能通过 F12 右键单击 - Go 定义或 Ctrl+单击。
Go to definition works just on typescript components, also I don't get any errors except "No definition found for...." Go 的定义仅适用于 typescript 组件,除了“没有找到...的定义”之外,我没有收到任何错误
I've tried updating VS Code, reinstalling VS Code and reinstalling extensions: Angular Essentials by John Papa Angular Language Service Angular Snippets我试过更新 VS Code,重新安装 VS Code 并重新安装扩展: Angular Essentials by John Papa Angular 语言服务 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在我的情况下,经过几次尝试,我发现原因是父 DOM 元素中的 * ngIf="whatever"以及在其他一些情况下在同一级别的其他元素中,删除它后,所有定义都可以再次访问......这是一个错误作为一种解决方法,我将 Angular 语言服务降级到 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:要启用最新的语言服务功能,请通过将 strictTemplates 设置为 true 来设置 tsconfig.json 中的 strictTemplates 选项,如下例所示:
content_copy "angularCompilerOptions": { "strictTemplates": true } content_copy "angularCompilerOptions": { "strictTemplates": true }
https://angular.io/guide/language-service https://angular.io/guide/language-service
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.