IntelliSense & _references.js 支持项目中未包含的文件

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

我有一个包含多个 JavaScript 脚本文件的 MVC 项目。其中一些文件需要进行单元测试。为此,我们有一个单独的 JS 文件。测试文件放在 Scripts 文件夹中,不包含在项目中(即 .csproj 文件中没有引用)。 _references.js.

中引用了我们所有的脚本文件

从 Visual Studio 打开时,测试文件对项目中包含的文件没有任何 IntelliSense 支持;既没有 jQuery 支持,也没有自定义脚本支持。请注意,Vanilla JS IntelliSense 有效。

是否可以通过 _reference.js 中的文件引用为项目中未包含的 JavaScript 个文件启用 IntelliSense 支持?

根据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

然后解决方案是在项目中未包含的文件的开头添加 _references.js 作为特定参考。

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

//other JS code

这会为 _references.js 文件启用 IntelliSense 支持,这反过来又会为其引用的文件启用 IntelliSense。