簡體   English   中英

為什么“可選參數名稱%s必須以opt_。為前綴”。在gjslint --strict模式下?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM