Destructuring require-call breaks code completion

I have an ES6 project (nwjs) with some frontend-libraries (underscore, knockout + more) that I need to import in many files.

For easy access to the libs, I defined a module "commons.js", similar to this:

module.exports = {

  _: require('./lib/underscore-min'),

  ko: require('./lib/knockout')

};

It allows me to write very compact destructuring require-statements for the libs I need, like:

let {_, ko} = require('./commons');

 

Now the code works fine, but Webstorm's code checker / completion is not working (e.g. marks _.* statements invalid etc).

If I import the libraries directly, code completion works.

let _ = require('./lib/underscore-min');

 

So it looks like Webstorm can't handle the import "hop" over commons.

Is there a way to make it work? 

I really don't want to repeat the same up to 8 require-calls in tens of files.

 

Thanks for your help!

0
1 comment

This issue is tracked as https://youtrack.jetbrains.com/issue/WEB-25571; please follow it for updates

0

Please sign in to leave a comment.