[英]Enabling javascript intellisense for external libraries in Visual Studio
I updated ~/Scripts/_references.js
with 我用
~/Scripts/_references.js
更新了~/Scripts/_references.js
/// <autosync enabled="true" />
/// <reference path="angular.js" />
/// <reference path="angular-route.js" />
and in my app.js
I can see some intellisense working, which is great 在我的
app.js
我可以看到一些intellisense工作,这很棒
but go a little further and it doesn't work anymore. 但是走得更远,它不再起作用了。
Any ideas on why this happens or ways to make it work? 有关为什么会发生这种情况或使其发挥作用的任何想法?
Because you are using dependency injection
, Visual Studio has no way to figure out what are the types of the arguments. 因为您正在使用
dependency injection
,所以Visual Studio无法确定参数的类型。
This is a common problem with Javascript intellisense and, since Javascript does not allow for explicit type annotations, it seems that there is no clear way to work around it. 这是Javascript intellisense的常见问题,并且由于Javascript不允许显式类型注释,似乎没有明确的方法来解决它。
However, this can be achieved easily using Typescript (which has a VS2013 extension) and angular types where your code would look like: 但是,这可以使用Typescript (具有VS2013扩展)和角度类型轻松实现,其中代码如下所示:
angular.module('example', ['ngRoute'])
.config([ '$locationProvider',
function ($locationProvider : ng.ILocationProvider) {
$locationProvider. // Intellisense would work here.
}
]);
I built a library to do just this: 我建了一个库就可以做到这一点:
https://github.com/jmbledsoe/angularjs-visualstudio-intellisense https://github.com/jmbledsoe/angularjs-visualstudio-intellisense
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.