Search code examples
javascriptwebstormcode-completiondynamic-properties

WebStorm: JavaScript code-complete for dynamically generated class methods


How to annotate a dynamically generated class method in WebStorm so it shows up in the autocomplete?

So far I was able to accomplish similar thing for properties:

/**
 * @property prop1
 * @property prop2
 */

class MyClass{
    //empty class
}

Now if I type new MyClass().pr then WebStorm shows both prop1 and prop2 in the code completion popup.

What is the correct syntax for methods?

It seems @name should do the trick, but WebStorm doesn't recognize it for autocompletion.

Or maybe it's not about annotations but there is a different way of accomplishing that?

Any IDEas?


Solution

  • Why not using @property for this? Like:

    /**
     * @property prop1
     * @property prop2
     * @property {function(string)} method1
     */
    
    class MyClass{}