/**
* @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?
Typescript doesn't care, so follow the conventions of your project. If you're starting a new project, most Javascript devs use capitalized words for classes, and since type aliases are conceptually similar to classes, I'd say capitalize them too. But the compiler doesn't care in the slightest.
java - Types like int, double, char, long, float all start with lowercase letter, except String type.
All the primitive types are lowercase, making Option A correct. Unlike object reference variables, primitives cannot reference null. String is not a primitive as evidenced by the uppercase letter in the name and the fact that we can call methods on it. You can create your own classes, but not primitives.
because it is a class, and it is common programming style to make the first letter of a class uppercase.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With