Classes and type hierarchy in JavaScript?

Just evaluating the WebStorm.

I have a bunch of code (~30 classes, 4000 lines of code), using lazy class syntax (animal example):

function Animal() {
    var self = this;
    this.legs = 0;    
    this.say = function () {
        console.log("I have this many legs:", self.legs);

function Donkey() {;
    var parent_say = this.say;    
    this.legs = 4;    
    this.say = function () {
        console.log("Also I'm donkey");

var d = new Donkey();

But it seems like the WebStorm doesn't recgonize these as classes. If I try "Go to Class" (Ctrl+N) it can't find any of the classes. Type Hierarchy is also very empty. I tried adding @class jsdoc to the some of those and it didn't help.

Is there a syntax which makes the WebStorm recgonize these as classes? If not can I rewrite my classes in some other way to make them recgonized?

I don't need a lecture on multiple ways of inheritance (or syntaxes people prefer) on JavaScript, I've read my Crockford. But still IDE developers must have done some decision, so which one of the syntaxes it recgonizes as classes?

*Sigh* thankfully the next EcmaScript may include class keyword.

Comment actions Permalink

Hi Jary,

what WebStorm version do you use? WebStorm 6 EAP does 'see' javascript classes marked with @class JSDoc tag. It also does recognize that Donkey in your sample is a child of Animal
In WS 6 'Go to class' works for jsdoc-annotated, ExtJS, Dojo and Google closure classes

Best regards,

Comment actions Permalink

P.S. I was using WebStorm 5, switching to 6 worked.


Please sign in to leave a comment.