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
source to share
No one has answered this question yet
Check out similar questions: