JSDoc has a @readonly
doclet tag:
The @readonly tag indicates that a symbol is intended to be read-only.
For example:
/**
* The name of the represented principal
* @member {string}
* @readonly
*/
this.name = primaryName;
However, what I really want to communicate and document is that public consumers should treat the property as read-only - but the member is not constant.
Internal code can, and does, modify such members: the read-only doclet tag is for the API consumers. (And if the API is used incorrectly, shame on them! - but not my concern.)
/**
* Update the security token information.
* (This is a made-up example!)
*/
this.updateToken = function (token) { this.name = token.name; }
Is there a good way to express this concept in JSDoc (tags)? In particular,
What is a good way to express "it is expected that internal code modifies this read-only member"?
Without writing such explicitly, aside from doclet tags, in the documentation of course.
I was originally hoping JSDoc would trivially accept "@readonly private" or similar, but such is not the case.. The issue with using a custom tag is that such is introduced locally, having no imminent external meaning or application in the standard templates.