gpt4 book ai didi

javascript - 为什么在 gjslint --strict 模式下是 "Optional parameter name %s must be prefixed with opt_."?

转载 作者:行者123 更新时间:2023-11-30 13:05:13 26 4
gpt4 key购买 nike

我在一个特定的 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 参数不是可选的,那么您应该将其类型更改为 string

这个错误的目的是确保清楚哪些参数是可选的(并且不仅它们的类型反射(reflect)了它,而且它们的名称也根据样式指南 gjslint正在使用),哪些不是。

关于javascript - 为什么在 gjslint --strict 模式下是 "Optional parameter name %s must be prefixed with opt_."?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15940419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com