[英]why “Optional parameter name %s must be prefixed with opt_.” in gjslint --strict mode?
我在一個特定的javascript文件上獲得以下內容
Line 23, E:0233: Optional parameter name category must be prefixed with opt_.
Line 649, E:0233: Optional parameter name animate must be prefixed with opt_.
Line 697, E:0233: Optional parameter name aggregate must be prefixed with opt_.
Line 763, E:0233: Optional parameter name animate must be prefixed with opt_.
Line 796, E:0233: Optional parameter name animate must be prefixed with opt_.
對於第一個代碼是:
/** @constructor
*
* @param {Object} data an entity or item.
* @param {Object} parent a viewObj, or at the root level, a viewstate.
* @param {Array.<number>} position an (x$, y$) pair.
* @param {string=} category The category to give the item. This forms an
* inconsistent mess around where category is stored.
*/
function ViewObj(data, parent, position, category) {
錯誤代碼有什么意義? 'category' 不是可選的!
該=
在類型后綴意味着它是可選的。 如果category
參數不是可選的,那么您應該將其類型更改為string
。
此錯誤的目的是確保清楚哪些參數是可選的(並且它們的類型不僅反映了它,而且它們的名稱也符合gjslint
使用的樣式指南),哪些不是。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.