Search code examples
jsdocjsdoc3

Do primitive type names need to be uppercase or lowercase?


/**
 * @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?


Solution

  • 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.