为什么“;成员不能具有@private JsDoc“;

Why is it that "Member must not have @private JsDoc"?

本文关键字:@private JsDoc 不能 成员 为什么      更新时间:2024-01-30

我正在用谷歌闭包工具中的gjslint工具清理我的代码。它报告了以下错误:

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

这是代码:

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

有人能解释一下为什么吗_字典不能有@private JsDoc?谢谢

Closure Linter旨在强制执行Google JavaScript样式指南。JSDoc标签@private记录如下:

与方法或属性名称上的尾部下划线一起使用,表示成员为私有成员。随着工具更新以强制执行@private,尾随下划线最终可能会被弃用。

从Closure Linter 2.3.6版本起,每当成员被注释为@private而没有尾部下划线时,就会发出错误"Member<name>must not have@private JsDoc"。

此代码不会发出任何错误或警告。

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