Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsdoc two dimensional array

I have an array of array of string and I can't figure out how to document that with JSDoc.

/**
@class
*/
function PostbackList() {
    /**
    @type {int}
    @default
    */
    this.TypeID = 0;
    /**
    @type {PostbackList.Field[]}
    */
    this.Fields = new Array();
    /**

    !! Issue here !!


    @type {string[][]}
    */
    this.Values = null;
}

Which results in errors.

Invalid type expression "string[][]": Expected "!", "?" or "|" but "[" found.

And I don't know if I should put ? in front of the type to indicate it can be null.

like image 855
Serge Profafilecebook Avatar asked Sep 01 '14 09:09

Serge Profafilecebook


2 Answers

According to what the current maintainer of jsdoc says in this issue report, as we speak jsdoc 3 cannot handle declaring multidimensional arrays by adding square brackets. You can do it like you did with Array.<string[]>, or with Array.<Array.<string>>.

According to the issue report, version 3.3.0 will allow the notation you wanted to use.

like image 159
Louis Avatar answered Sep 29 '22 23:09

Louis


Louis answer is valid, but the maintainer updated the repository and now also the code you provided is valid:

@type {string[][]}
like image 33
YarnSeemansgarn Avatar answered Sep 29 '22 23:09

YarnSeemansgarn