C
C
ChernovGV2020-10-11 08:53:07
phpstorm
ChernovGV, 2020-10-11 08:53:07

Why doesn't autocomplete work in PhpStorm|WebStorm for JS objects?

For some reason, the methods and properties of objects in PhpStorm's autocomplete are not picked up (in WebStorm - also, specially set):
5f829933e1635708458554.png
Although,

the RepeatResultDTO class contains a test property and a method:

module.exports = class RepeatResultDTO {

    /**
     * @param repeatResultBool
     * @param resultPower 0 - is default action; 1-N move step.
     */
    constructor(repeatResultBool = true, resultPower = 0) {
        this._resultBool = repeatResultBool;
        this._resultPower = resultPower;
        this.testVar = true;
    }

    /**
     * @return {boolean}
     */
    get resultBool() {
        return this._resultBool;
    }

    /**
     * @return {number}
     */
    get resultPower() {
        return this._resultPower;
    }

    testMethod()
    {
        return this.testVar;
    }
}

The resultPower() and resultBool() methods are also not visible in the autocomplete :(

And:
5f82a3dfd978e362251861.png

Tell me what could be the matter?

JS settings in IDE

5f829cf2c7e6b268626701.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
ChernovGV, 2020-10-11
@ChernovGV

The thing is that you need to export classes not like this:

module.exports = class SomeClass {
    //...
}

But like this:
class SomeClass {
    //...
}
module.exports = SomeClass;

R
Robur, 2020-10-11
@Robur

No one will help you better than the ide developers themselves :)
maybe some kind of bug, open a ticket here https://youtrack.jetbrains.com/issues/WEB
they always answer, quite quickly and if the problem is clear - they fix it, or they say that you you're doing it wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question