7.3 JSDoc tags
Google style allows a subset of JSDoc tags. See?? for the complete list. Most tags mustoccupy their own line, with the tag at the beginning of the line.
Disallowed:
/**
* The "param" tag must occupy its own line and may not be combined.
* @param {number} left @param {number} right
*/
function add(left, right) { ... }
Simple tags that do not require any additional data (such as @private
,@const
, @final
, @export
) may be combined onto the same line, along with anoptional type when appropriate.
/**
* Place more complex annotations (like "implements" and "template")
* on their own lines. Multiple simple tags (like "export" and "final")
* may be combined in one line.
* @export @final
* @implements {Iterable<TYPE>}
* @template TYPE
*/
class MyClass {
/**
* @param {!ObjType} obj Some object.
* @param {number=} num An optional number.
*/
constructor(obj, num = 42) {
/** @private @const {!Array<!ObjType|number>} */
this.data_ = [obj, num];
}
}
There is no hard rule for when to combine tags, or in which order, but beconsistent.
For general information about annotating types in JavaScript seeAnnotating JavaScript for the Closure Compiler and Types in the Closure TypeSystem.