Wednesday, April 18, 2012

How can I avoid for an undeclared variable breaking Intellisense?

Yeah, I can already see the upcoming comment trail along the lines of "use declared variables then". But please bear with me.



The situation is that I have a moderate pile of JS files, each containing a Dojo widget. Widgets contain calls to various functions in dojo namespace but because dojo does not exist in the scope of a widget file, Intellisense breaks.



Here CTRL+[space] autocomplete includes this.a and this.b as expected:



new Object({
a: NaN,
b: function YesToIntellisense()
{
console.log(this.a); // CTRL+[space] includes this.a and this.b
}
});


Here CTRL+[space] autocomplete lacks both this.a and this.b:



new Object({
a: dojo.foo(),
b: function NonIntellisense()
{
console.log(this.a); // CTRL+[space] does *not* include this.a and this.b
}
});


How can I avoid for an undeclared variable breaking Intellisense in VS2010?





No comments:

Post a Comment