简体   繁体   中英

Enabling javascript intellisense for external libraries in Visual Studio

I updated ~/Scripts/_references.js with

/// <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

angular.js intellisense工作

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

angular.js intellisense无法正常工作

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.

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.

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.
    }
   ]);

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