Question

I'm cleaning up my code with the gjslint tool from Google Closure Tools. It is reporting the following error:

Line 15, E:0222: Member "this._dictionary" must not have @private JsDoc

And this is the code:

/**
 * Stacker class.
 * @constructor
 * @param {frankenstein.app.Dictionary} dictionary input dictionary for stacking.
 */
frankenstein.app.Stacker = function(dictionary) {
  /** @private */ this._dictionary = dictionary;
};

Can somebody explain why this._dictionary must not have @private JsDoc? Thanks!

Was it helpful?

Solution

Closure Linter is designed to enforce the Google JavaScript Style Guide. The JSDoc tag @private is documented as follows:

Used in conjunction with a trailing underscore on the method or property name to indicate that the member is private. Trailing underscores may eventually be deprecated as tools are updated to enforce @private.

As of Closure Linter version 2.3.6, the error "Member <name> must not have @private JsDoc" will be emitted whenever a member is annotated @private without a trailing underscore.

This code will not emit any errors or warnings.

/**
 * Stacker class.
 * @constructor
 * @param {frankenstein.app.Dictionary} dictionary Input dictionary for 
 *     stacking.
 */
frankenstein.app.Stacker = function(dictionary) {
  /** @private */ this.dictionary_ = dictionary;
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top