@enum
Syntax
@enum {type}
Overview
@enum marks an object as an enumeration — a set of related named constants that share the same type. Each property of the object becomes a member of the enum.
TSTypeScript Supported
TypeScript uses @enum to define enumerations in JavaScript files, similar to TypeScript enum declarations.
Example
/**
* Possible states for a connection.
* @enum {number}
*/
const ConnectionState = {
/** The connection is being established. */
CONNECTING: 0,
/** The connection is open and ready. */
OPEN: 1,
/** The connection is closing. */
CLOSING: 2,
/** The connection is closed. */
CLOSED: 3,
};
String enum
/**
* Supported log levels.
* @enum {string}
* @readonly
*/
const LogLevel = {
DEBUG: 'debug',
INFO: 'info',
WARN: 'warn',
ERROR: 'error',
};
tip
Combine @enum with @readonly to signal that the values should not be modified at runtime.
See also
Official reference: jsdoc.app/tags-enum