0

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?

glosrob
  • 6,631
  • 4
  • 43
  • 73
  • 2
    No, you haven't defined it incorrectly. (That's not a *namespace*, it's just an object, but that's just terminology.) Seems to be a bridge too far for the vscode analyzer, though. (I can replicate your results.) – T.J. Crowder Jan 31 '18 at 15:30
  • [Example 1](https://stackoverflow.com/questions/48537587/vs-code-1-19-3-debugging-net-core-2-and-always-meet-only-64-bit-processes-can) [Example 2](https://stackoverflow.com/questions/48538235/how-to-set-up-vue-files-formatting-in-vs-code) [Example 3](https://stackoverflow.com/questions/48536639/why-my-visual-studio-code-lacks-html) [Example 4](https://stackoverflow.com/questions/48527394/visual-studio-code-intelisense-stopped-to-work-on-c-sharp-files) [Example 5](https://stackoverflow.com/questions/48529466/what-would-it-take-to-enable-intellisense-in-a-vue-components-template-html) – Jacob H Jan 31 '18 at 15:37
  • Those are just examples from the past 12 hours. – Jacob H Jan 31 '18 at 15:38
  • Hell, even a 6th example since I started making this comment: https://stackoverflow.com/questions/48545919/visual-studio-code-nodemon-econnrefused-after-10-s-of-debugging Sorry to hijack the comments but this is kind of silly that nearly everyone seems to have problems with intellisense and debugging in Code. – Jacob H Jan 31 '18 at 15:39

0 Answers0