rcplusplus
rcplusplus

Reputation: 2877

Visual studio code - Intellisense across JS modules

In the new VS Code editor, let's say I have two javascript files foo.js and bar.js with bar.js containing this:

module.exports.sayBar = function () {
    console.log('bar')
}

In foo.js, if I type require('./bar'). and hit ctrl+space to activate intellisense, it doesn't detect that one of the methods in the module is sayBar() (I already have the default jsconfig.json file that VS Code asks if you want to generate).

Is there some other configuration step to activate intellisense for other JS files that I've written? I really liked that feature for C++ projects in VS Express and it would cause VS Code to blow Atom completely out of the water IMO.

Upvotes: 1

Views: 838

Answers (1)

Dauren Akilbekov
Dauren Akilbekov

Reputation: 5035

It does work for CommonJS modules. In your example it should be:

exports.sayBar = function() {
  console.log('bar');
};

or

module.exports = {
  sayBar: function() {
    console.log('bar');
  }
};

enter image description here

Upvotes: 1

Related Questions