2013-04-11 26 views
1

我得到以下在一個特定的JavaScript文件爲什麼「可選參數名稱%s必須以opt_爲前綴。」在gjslint - 嚴格模式下?

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'是不是可選!

回答

3

=類型的後綴表示它是可選的。如果category參數不是可選的,則應將其類型更改爲string

此錯誤的目標是確保清楚哪些參數是可選的(並且不僅它們的類型反映它,而且它們的名稱以及根據樣式指南gjslint正在使用),以及哪些不是。

+0

啊,好吧,嗯。有時間臉紅。謝謝。 – bugmagnet 2013-04-11 03:52:58

相關問題