启用JavaScript智能感知在Visual Studio外部库 [英] Enabling javascript intellisense for external libraries in Visual Studio

查看:336
本文介绍了启用JavaScript智能感知在Visual Studio外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新〜/脚本/ _references.js

/// <autosync enabled="true" />
/// <reference path="angular.js" />
/// <reference path="angular-route.js" />

在我的 app.js 我可以看到一些智能感知的工作,这是伟大的。

and in my app.js I can see some intellisense working, which is great

但走远一点,它不工作了。

but go a little further and it doesn't work anymore.

这是为什么发生这种情况或任何方式的思路,使工作?

Any ideas on why this happens or ways to make it work?

推荐答案

由于您使用的是依赖注入时,Visual Studio有没有办法找出哪些类型参数。

Because you are using dependency injection, Visual Studio has no way to figure out what are the types of the arguments.

这是 JavaScript智能一个共同的问题,而且由于JavaScript不容许明确类型标注,似乎没有解决它明确的方式。

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.

然而,这可以容易地使用打字稿(其具有VS2013扩展名)和angular类型的在您的code看起来像:

However, this can be achieved easily using Typescript (which has a VS2013 extension) and angular types where your code would look like:

angular.module('example', ['ngRoute'])
  .config([ '$locationProvider',
    function ($locationProvider : ng.ILocationProvider) {

           $locationProvider. // Intellisense would work here.
    }
   ]);

这篇关于启用JavaScript智能感知在Visual Studio外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆