Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

IntelliSense for JavaScript Files (.js) in Visual Studio

0.00/5 (No votes)
15 Oct 2014 1  
IntelliSense for JavaScript files (.js) in Visual Studio

Introduction

In Visual Studio, we get IntelliSense support for JavaScript in our markup files (.html or .aspx) when we include these references using the <script> tag.

<script src="Scripts/angular.js"></script>

<script src="Scripts/angular-route.js"></script>

But what if we are writing pure JavaScript (.js) files which will later be included in our markups. We look for IntelliSense pressing the Ctrl+Spacebar, but don’t find any and it gets really annoying, as we are so used to IntelliSense in Visual Studio.

In order to support IntelliSense in such files (.js), we have to add a /// <reference path="[file path]”> tag to our JavaScript files, to activate the IntelliSense for the referenced JavaScript file.

/// <reference path="../Scripts/angular.js" />

/// <reference path="../Scripts/angular-route.js" />

An example below...

Here, we are getting expected JavaScript IntelliSense support.

Once our app.js is created, we add it to our markup as follows:

    <script src="Scripts/angular.js"></script>
    <script src="Scripts/angular-route.js"></script>
    <script src="app/app.js"></script>

Our markup though would need the referenced JavaScript files included in the <script> tags as well!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here