I open VSCode and create test.js
and write something like:
var test = (function () {
return {
foo: function () {
//foo
},
bar: function () {
//foo
}
};
})();
Start typing test
and I can see suggested for me via intellisense foo
and bar
, and I F12 on either it takes me to the definition.
Now if I introduce a namespace, like so:
var test = test || {};
test.rob = (function () {
return {
foo: function () {
//foo
},
bar: function () {
//foo
}
};
})();
Intellisense 'loses' the definition, doesn't highlight foo
and bar
and won't go to definition when using F12.
Any idea why? Have I defined my JavaScript incorrectly perhaps?