I would like to use Visual Studio's IntelliSense but it doesn't work in this situation. Here is an example of what I am trying to do:
// IntelliSense doesn't work.
Namespace.Class = (function () {
/** A class. */
function Class() {
/** A method. */
this.method = function () {
console.log("test 1");
};
}
return Class;
}());
// Intellisense works.
/** A class. */
Namespace2.Class = function () {
/** A method. */
this.method = function () {
console.log("test 2");
};
};
Not working:
Working:
Try the following snippet. For some unknown reason, Intellisense infers the result of the function as typeof Class
instead of just Class
. To fix it typecast the type back to Class
again.
Namespace.Class = (function () {
/** A class. */
function Class() {
/** A method. */
this.method = function () {
console.log("test 1");
};
}
return /** @type {Class} */(/** @type {unknown} */(Class));
}());