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:

  1. /**
  2. * The "param" tag must occupy its own line and may not be combined.
  3. * @param {number} left @param {number} right
  4. */
  5. 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.

  1. /**
  2. * Place more complex annotations (like "implements" and "template")
  3. * on their own lines. Multiple simple tags (like "export" and "final")
  4. * may be combined in one line.
  5. * @export @final
  6. * @implements {Iterable<TYPE>}
  7. * @template TYPE
  8. */
  9. class MyClass {
  10. /**
  11. * @param {!ObjType} obj Some object.
  12. * @param {number=} num An optional number.
  13. */
  14. constructor(obj, num = 42) {
  15. /** @private @const {!Array<!ObjType|number>} */
  16. this.data_ = [obj, num];
  17. }
  18. }

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.