JSDoc: Unresolved variable under certain circumstances

Hello!

In the following code snippet the code inspection of PhpStorm 6.0.3 considers the private property "_bar" unresolved:

var module = function() {
    /** @constructor */
    function FooBar() {
        this.foo = 'foo';
        /** @private */
        this._bar = 'bar';
    }
    FooBar.prototype = {
        getFoo: function() {
            return this.foo;
        },
        getBar: function() {
            return this._bar; // "Unresolved variable _bar"
        }
    };
    return {};
}();


However, "_bar" is recognized correctly if I change the code like this:

(function() {
    var module = window.module = {};
    /* code omitted */
})();


Or like this:

var module = function() {
    /* code omitted */
    return {_bar: undefined};
}();


So the code inspection seems to assume that "_bar" is a property of "module" instead of "FooBar".

This doesn't seem to happen with all private properties, though. In a somewhat larger script of mine I have a constructor with several private properties of which only two cannot be resolved. If a I apply one of the changes mentioned above, they can be resolved without problems.

Is this a bug or am I doing something wrong (first time for me using JSDoc)?
I did a search in the issue tracker but couldn't find a related bug.

Best wishes
Endgegner out

1 comment
Comment actions Permalink

_bar will be resolved if you remove @private annotation; fixed in WebStorm 7

0

Please sign in to leave a comment.