Skip to main content

@private

Syntax

@private

Overview

@private marks a symbol as private. Private symbols are documented by JSDoc but are excluded from default output unless the --private flag is used.

TypeScript Supported

TypeScript recognises @private and uses it to restrict access to class members in JavaScript files.

TypeScript docs →

Example

class Cache {
constructor() {
/**
* Internal storage map.
* @private
* @type {Map}
*/
this._store = new Map();
}

/**
* Flush the entire cache.
* @private
*/
_flush() {
this._store.clear();
}
}
tip

By convention, private members are also prefixed with an underscore (_), but @private is the authoritative signal for documentation tools.

See also

Official reference: jsdoc.app/tags-private