4

Let's say I define a property with Object.defineProperties(). If I try to specify the type of this property with a JSDoc comment, WebStorm gives me a warning.

Here is an example:

Object.defineProperties(obj, {

    /**
     * @type {String}
     */
    example: { get: function() { return 'example'; } }
}

This will give me the following WebStorm warning: Initializer type {get: Function} is not assignable to variable type String.

If I switch to the following, the warning goes away but the generated documentation does not say that a "string" is expected:

Object.defineProperties(obj, {

    /**
     * @type {get: Function}
     */
    example: { get: function() { return 'example'; } }
}

Any ideas on how to fix this ?

djip.co
  • 997
  • 10
  • 17
  • I'm not an expert here, but could you just document it elsewhere as a property on `obj` with `@property {string} example`? – apsillers Dec 03 '14 at 16:57
  • @apsillers If I move the whole comment block outside Object.defineProperties() the warning goes away. However, I would much prefer to have the comment right above where the property is defined. Isn't that possible ? – djip.co Dec 03 '14 at 17:09

0 Answers0