基本类型名称需要大写还是小写?
Do primitive type names need to be uppercase or lowercase?
/**
* @param {String} foo
* @param {Number} bar
*/
或
/**
* @param {string} foo
* @param {number} bar
*/
JSDoc @type
文档没有明确说明。
我总是大写 String
和 Number
因为我的理解是我需要使用构造函数名称。在 JavaScript 中,String
and Number
作为构造函数存在。
我注意到不一致:我将其他基本类型(例如 null
、undefined
)定义为小写。
原始类型名称需要大写还是小写?
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.
我倾向于使用小写,因为 typeof
运算符 returns 小写。
/**
* @param {String} foo
* @param {Number} bar
*/
或
/**
* @param {string} foo
* @param {number} bar
*/
JSDoc @type
文档没有明确说明。
我总是大写 String
和 Number
因为我的理解是我需要使用构造函数名称。在 JavaScript 中,String
and Number
作为构造函数存在。
我注意到不一致:我将其他基本类型(例如 null
、undefined
)定义为小写。
原始类型名称需要大写还是小写?
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.
我倾向于使用小写,因为 typeof
运算符 returns 小写。