JavaScript IntelliSense in Visual Studio 2015 and 2017 - The current stand, as of 2018

If you are writing vanilla JavaScript in a large web application, it is almost certain that you are dealing with multiple JavaScript files which are scattered in multiple Visual Studio projects, stored in different solutions. Visual Studio does not provide any IntelliSense features for referenced code which sits outside of the current project.

One solution to this problem is to manually search for the specific file and find out which arguments does your function need or which functions are contained in a JavaScript object. Since this can be a tedious action, Visual Studio gives us the option to activate IntelliSense in our JavaScript files by creating a file named _references.js. TypeScript users are already experiencing the benefits of code completion by using the d.ts definition files.

The use of _references.js is not a new feature. It exists for many years now, however, with this article I want to give you the current stand of the feature, as of 2018. I want to find out if the file still does what is supposed in Visual Studio 2015 and 2017.

I have checked both versions of Visual Studio and I can definitely say that _references.js still works like a charm.

Here are some important tips that you have to keep in mind while using this file in your projects:

* The file has to be inside a folder called **Scripts**. The position of this folder inside your project is up to you. In some of my tests the folder was inside a "StaticContent" folder and the feature still worked. ![The _references.js file in action](https://christosmonogios.com/public/images/2018/02/references-file-inside-other-folders.png)

* Inside this file you can reference files, by using relative paths, from other projects and even files living in different solutions. You get the IntelliSense features **only for listed files** inside *_references.js*. Here is an example where we reference JavaScript code from two external solutions: ![The _references.js file in action](https://christosmonogios.com/public/images/2018/02/references-file-from-different-projects-visual-studio-2015-2017.png)

* Clicking F12 on a method or property of a referenced file will even open the file in Visual Studio!

* Every JavaScript file inside a project in which a *_references.js* file exists, gets code completion. The same counts for inline JavaScript code which **does not** need any use of the ```///<reference ...``` file. 

No need to use the _references.js file in files inside the Script folder

Moreover, I have to mention that the _references.js file works also on .NET Core projects:

_references.js file works also in .NET Core projects

I still use this file as it increases my productivity by saving me time. In case you still write plain JavaScript, IntelliSense in your JavaScript files is pure gold! In this MSDN article you can find more information about JavaScript Intellisense.

comments powered by Disqus