Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't document enums

I'm trying to document an enum like this:

/**
 * Enum for the different types of tokens
 * @memberof Ecre
 * @enum {number}
 * @readonly
 */
Ecre.TokenTypes = Object.freeze({
    /**
     * A string token
     */
    "string": 1,
    "comment": 2,
    "number": 3,
    "boolean": 4,
    "identifier": 5
});

But this doesn't not work as excepted: string is being document as a global.

How can I achieve that the values are documented in a proper way?

I'm using JSDoc 3.3.0-alpha9 (Sat, 28 Jun 2014 15:26:03 GMT)

like image 453
idmean Avatar asked Oct 26 '25 05:10

idmean


1 Answers

It's pretty old question, but an answer still could be helpful. Since Object.freeze freezes the object, you can call it after enum is defined.

/**
 * Enum for the different types of tokens
 * @memberof Ecre
 * @enum {number}
 * @readonly
 */
Ecre.TokenTypes = {
    "string": 1,
    "comment": 2,
    "number": 3,
    "boolean": 4,
    "identifier": 5
};
Object.freeze(Ecre.TokenTypes);
like image 102
milhauz Avatar answered Oct 28 '25 19:10

milhauz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!