15
/**
 * @param {String} foo
 * @param {Number} bar
 */

or

/**
 * @param {string} foo
 * @param {number} bar
 */

JSDoc @type documentation is not being explicit about it.

I always uppercase String and Number because it is my understanding that I need to use the constructor name. In JavaScript, String and Number exist as constructors.

I have noticed inconsistency: I am defining other primitive types (e.g. null, undefined) as lowercase.

Do primitive type names need to be uppercase or lowercase?

Community
  • 1
  • 1
Gajus
  • 55,791
  • 58
  • 236
  • 384

1 Answers1

19

It doesn't matter:

JSDoc doesn't care. It's up to the user's preference. I tend to use lowercase for primitive types (and function, for some reason) and uppercase for Array and Object.

I tend to use lowercase because the typeof operator returns lowercase.

Gajus
  • 55,791
  • 58
  • 236
  • 384
chib
  • 545
  • 4
  • 12
  • 1
    I have created an ESLint plugin that enforces consistent type case (among other things), https://github.com/gajus/eslint-plugin-jsdoc – Gajus Feb 09 '16 at 10:05
  • 7
    Author of [the linked issue](https://github.com/jsdoc3/jsdoc/issues/1046) here. If you look at how many other projects have been linking to that issue, it suggests that developers *are* looking for guidance. Saying "JSDoc doesn't care" ignores this quest for guidance. – Dan Dascalescu Jan 19 '19 at 18:25