joniba
joniba

Reputation: 3499

How to get WebStorm to recognize class methods node.js

I'm using WebStorm 11.0.3 with ES6 and node language support activated. I have a class, for example:

// File thing.js
'use strict';
module.exports = class Thing {
    static do(){
        console.log('thing.do1');
    }

    do(){
        console.log('do');
    }
};

Now I want to use this class. If I give the class a different name in the require, I don't get intellisense. E.g., this works:

// File do1.js
'use strict';
var Thing = require('./thing');

Thing.do();
new Thing().do();

But this doesn't (no intellisense on thing, no go-to-declaration, etc.)

// File do2.js
'use strict';
var thing = require('./thing');

thing.do();
new thing().do();

Is there any way around this wierdness?

Upvotes: 2

Views: 939

Answers (1)

Julia
Julia

Reputation: 44

As a workaround you can change module.exports = class Thing to the export default class Thing

And thanks for the question - appropriate issue was created (https://youtrack.jetbrains.com/issue/WEB-20854)

Upvotes: 1

Related Questions