Visual Studio 2015 中没有 IntelliSense for AngularJS TypeScript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32288505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:04:51  来源:igfitidea点击:

No IntelliSense in Visual Studio 2015 for AngularJS TypeScript

angularjstypescriptvisual-studio-2015intellisense

提问by maxmantz

I'm building an app using ASP.NET 5 & AngularJS in TypeScript in Visual Studio 2015. However, even after installing the AngularJS Core & DefinitelyTyped TS references for AngularJS via NuGet, I still don't get IntelliSense for the AngularJS libraries.

我正在 Visual Studio 2015 中使用 TypeScript 中的 ASP.NET 5 和 AngularJS 构建应用程序。但是,即使在通过 NuGet 为 AngularJS 安装了 AngularJS 核心和绝对类型化 TS 参考之后,我仍然没有获得 AngularJS 库的智能感知。

I'm also using the ReSharper 9.1 AngularJS extension, which gives me IntelliSense in HTML files but not in my TypeScript code.

我还使用了 ReSharper 9.1 AngularJS 扩展,它在 HTML 文件中为我提供了 IntelliSense,但在我的 TypeScript 代码中没有。

I've also noticed that even though the references to AngularJS and the definition files are present, the files themselves are nowhere to be found in my solution. Does anybody know how to fix this?

我还注意到,即使存在对 AngularJS 和定义文件的引用,在我的解决方案中也找不到这些文件本身。有谁知道如何解决这个问题?

Edit: I have found the solution. Read my answer if you're having the same problem.

编辑:我找到了解决方案。如果您遇到同样的问题,请阅读我的回答。

采纳答案by maxmantz

I have found a solution to my problem using the DefinitelyTyped Definition Manager: http://definitelytyped.org/tsd/

我找到了使用绝对类型定义管理器解决我的问题的方法:http: //definelytyped.org/tsd/

I've installed tsd globally using NPM:

我已经使用 NPM 全局安装了 tsd:

npm install -g tsd

then using a command prompt in the root folder of my solution, I've installed the AngularJS type definitions by entering the following command:

然后在我的解决方案的根文件夹中使用命令提示符,我通过输入以下命令安装了 AngularJS 类型定义:

tsd install angular

It automatically downloaded the type definitions into a folder named "typings/angularjs" and IntelliSense started working as intended.

它会自动将类型定义下载到名为“typings/angularjs”的文件夹中,并且 IntelliSense 开始按预期工作。

I can also confirm that using this approach, no NuGet packages of AngularJS Core or the DefinitelyTyped definitions are needed and ReSharper does not block IntelliSense.

我还可以确认,使用这种方法,不需要 AngularJS Core 的 NuGet 包或绝对类型定义,并且 ReSharper 不会阻止 IntelliSense。

UPDATE:

更新:

It seems like TSD is about to be deprecated and replaced by the typings project. It integrates well with TSD as well and has specific options for TSD users. While TSD still works fine, keep in mind that in the future TSD might not be maintained anymore.

似乎 TSD 即将被弃用并被typings 项目取代。它也与 TSD 很好地集成,并为 TSD 用户提供了特定的选项。虽然 TSD 仍然可以正常工作,但请记住,将来可能不再维护 TSD。

回答by B.K.

There's an add-on for the AngularJS Intellisense:

AngularJS Intellisense 有一个附加组件:

PM> Install-Package AngularJS.Intellisense

PM> Install-Package AngularJS.Intellisense

https://www.nuget.org/packages/AngularJS.Intellisense/

https://www.nuget.org/packages/AngularJS.Intellisense/

There's also a known issue with Resharper blocking JS intellisense. Turn it off and see if it makes any difference.

Resharper 阻止 JS 智能感知还有一个已知问题。关闭它,看看它是否有任何区别。