How can I document a property defined with Object.defineProperties () in WebStorm (JSDoc)

Let's say I am defining 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's an example:

Object.defineProperties(obj, {

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

      

This will give me the following WebStorm warning: The initializer type {get: Function} is not assigned to a variable of type String.

If I switch to the following, the warning goes away, but the generated documentation doesn't say a "string" is expected:

Object.defineProperties(obj, {

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

      

Any ideas on how to fix this?

+3
javascript webstorm jsdoc yuidoc


source to share


No one has answered this question yet

Check out similar questions:

5722
How can I remove a property from a JavaScript object?
2817
How can I upload files asynchronously?
2701
How do I get the values โ€‹โ€‹of a query string in JavaScript?
2414
How can I find out which radio button is selected using jQuery?
2288
How can I convert a string to boolean in JavaScript?
2284
How can I combine properties of two JavaScript objects dynamically?
2245
How do I refresh the page using jQuery?
3
Options parameter attribute with JSDoc in WebStorm: "Unresolved variable"
2
Determine JSDoc Type Using Variable [WebStorm-friendly]
0
Webstorm does not show warning for Jsdoc errors



All Articles
Loading...
X
Show
Funny
Dev
Pics