Quantcast
Channel: JetBrains Developer Community : All Content - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5481

Optimal JSDoc annotations for JS code completion

$
0
0

I have a large JS project with namespacing and inheritance. I'm looking for some tips for the optimal JSDoc annotations to use to get code completion working in IDEA 12.

 

Here are some quick classes for demonstration.

ClassA
// ...namespace setup here...

/**
 * @class ClassA
 */
com.demo.jstest.ClassA = function ClassA() {
    this.functionOnClassA = function() {};
};
ClassB
// ...namespace setup here...

/**
 * @class ClassB
 * @extends ClassA
 */
com.demo.jstest.ClassB = function ClassB() {
    // ...inheritance setup here...    this.functionOnClassB = function() {};
};
Client
// ...namespace setup here...

/**
 * @param {ClassA} classAInstance
 * @param {ClassB} classBInstance
 * @class Client
 */
com.demo.jstest.Client = function Client(classAInstance, classBInstance) {
    // Want to use code completion here
};

In Client, code completion works as expected for the direct members of each class; i.e. classAInstance has functionOnClassA and classBInstance has functionOnClassB. But classBInstance does not have functionOnClassA, despite the @extends annotation.

 

If I replace all of the class names in the JSDoc annotations with fully-qualified names (i.e. com.demo.jstest.ClassA, com.demo.jstest.ClassB, etc.), the code completion does start including functionOnClassA on the classBInstance.

 

Do I really need to put fully-qualified names everywhere in my JSDoc annotations, or can I use some other combination of JSDoc tags to get the desired result?


Viewing all articles
Browse latest Browse all 5481

Trending Articles