Andrei V
Andrei V

Reputation: 7506

IntelliSense & _references.js support for files not included in the project

I have a MVC project with several JavaScript script files. Some of these files need to be unit-tested. For that, we have a separate JS file. The test file is placed in the Scripts folder and is not included in the project (i.e. no reference in the .csproj file). All our script files are referenced in _references.js.

The test file, when opened from Visual Studio, does not have any IntelliSense support for the files include in the project; there is nor jQuery support, nor custom scripts support. Please note that Vanilla JS IntelliSense works.

Is there a way of enabling IntelliSense support from the files references in _reference.js, for JavaScript files that are not included in the project?

Upvotes: 1

Views: 1056

Answers (1)

Andrei V
Andrei V

Reputation: 7506

According to Mads Kristensen

There are several ways of implementing Intellisense for JavaScript. The three I remember being discussed were:
1. All .js files in the project are automatically included in Intellisense
2. Only .js files included on the same HTML pages are included
3. The user can manually reference other .js files

The solution then was to add _references.js as a specific reference at the begining of the file not included in the project.

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

//other JS code

This enables IntelliSense support for the _references.js file, which in turn enables IntelliSense for the files it references.

Upvotes: 0

Related Questions