17

I've recently started using jsdoc comments for documenting our javascript code, however I'm finding conflicting examples of the usage of the @param tag.

See https://code.google.com/p/jsdoc-toolkit/wiki/TagParam (PascalCase)

and https://developers.google.com/closure/compiler/docs/js-for-compiler (camel/lowercase).

camelCase makes sense to me since:

var foo = 1;
console.log(typeof foo); // outputs "number"

What's the correct casing to use for jsDoc @param comments? Or does it not matter? I'm planning to use it for document generation as well as running the code through google closure to get type checking.

Thanks!

magritte
  • 7,396
  • 10
  • 59
  • 79

1 Answers1

16

The conflicting examples for JSDoc type expressions involve the JavaScript primitive types string, number and boolean, which have corresponding wrapper types: String, Number, and Boolean.

From Closure: The Definitive Guide:

The use of wrapper types is prohibited in the Closure Library, as some functions may not behave correctly if wrapper types are used where primitive types are expected.

See MDN: Distinction between string primitives and String objects.

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117