How do you JSDoc annotate a method whose only parameter is an array of Objects?
I use the following JSDoc line:
- Code: Select all
@param {Array<Object>} a An array of Objects
which seems to satisfy the JSDoc parser, but when referencing Object members, the following warning is emitted:
The property member_name is undefined for the Javascript type Object.
Meta-code that emits the error:
- Code: Select all
for ( var i = 0; i < a.length; i++ )
{
var o = a[ i ]
var x = o.member_name
<more code>
}
I tried various permutations of the Object double-braces notation in the @param line of code, but the JSDoc parser complains:
{{ member_1 : String, member_2 : Number, member_3 : Boolean }}
By the way, the method's code works as expected...it's just the JSDoc warnings that I cannot seem to clear.
EDIT: Never mind...I figured it out. Keep the JSDoc @param as is and add @type with the double-braces detail to the declared Object in the code.