why "Optional parameter name %s must be prefixed with opt_." in gjslint --strict mode?

StackOverflow https://stackoverflow.com/questions/15940419

  •  03-04-2022
  •  | 
  •  

문제

I get the following on one particular javascript file

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_.

For the first one the code is:

/** @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) {

What's the point of the error code? 'category' is not optional!

도움이 되었습니까?

해결책

The = suffix in the type means that it's optional. If the category parameter isn't optional, then you should change its type to string.

The goal of this error is to make sure that it's clear which parameters are optional (and that not only does their type reflect it, but their name as well, in accordance with the style guide gjslint is using), and which are not.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top