I have a JavaScript wrapper that I initialize on body load and set to a global variable. Just after creating the object, I have full intellisense, but when referring to it later, from another function, the intellisense is lost. I presume this is because of dynamic typing:
var myWrapper;
function onload() {
myWrapper = new Wrapper(args);
myWrapper. //Intellisense here.
}
function whatever() {
myWrapper. //Intellisense lost.
}
I get round this by pretending to create the object again before my code, and then deleting the line:
function whatever() {
myWrapper = new Wrapper(); //Pretend to create object again.
myWrapper. //Intellisense returns!
}
Has the inference been improved in Visual Studio 2010, or is there any way to tell JavaScript about the type of object I’m currently working on?
Unless you tell is what type it is (by using the
newkeyword, it’s going to have a hard time guessing what it is…For example, consider the following
so yeah, perhaps allow your object to be set (Without args as you have) and put it at the top…