How to reference multiple files for javascript IntelliSense in VS2010

后端 未结 4 361
挽巷
挽巷 2020-12-15 16:22

I have large solution with about 40 separate javascript files, which are referenced to web page via special js-service. I want to use new IntelliSense features in VS2010, bu

相关标签:
4条回答
  • 2020-12-15 17:03

    You can select a bunch of them in Solution Explorer and drag them onto the editor of the JS file you want to use Intellisense.

    It will automatically generate the /// tags based on the file you dragged.

    0 讨论(0)
  • 2020-12-15 17:11

    I am using VS2010, have the same problem as user512395. It used to work for me with the chosen answer. I have upgraded to latest Resharper that comes with Javascript intellisense support recently.

    0 讨论(0)
  • 2020-12-15 17:16

    Add the references to one js file, ideally one that all the others rely on or use. Then everywhere else, include a reference to just that one js file.

    ie, file1.js contains:

    /// <reference path="file2.js" />
    /// <reference path="file3.js" />
    ...
    /// <reference path="file40.js" />
    

    And every other file contains just one reference:

    /// <reference path="file1.js" />
    

    Update for Visual Studio 2012: You can now put global references in the _references.js file so that intellisense is available automatically in other js files. You can also specify intellisense files in the tools dialog under "Tools" > "Options" > "Text Editor" > "JavaScript" > "Intellisense" > "References".

    More detail in this blog post: JavaScript Intellisense in VS 2012, The _references.js File

    0 讨论(0)
  • 2020-12-15 17:22

    It is very important that the ///... lines come before ANYTHING ELSE in your js file. There must not even be a blank line.

    Then all should work fine.

    0 讨论(0)
提交回复
热议问题