gpt4 book ai didi

javascript - 为什么是 "Member must not have @private JsDoc"?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:36:08 25 4
gpt4 key购买 nike

我正在使用 Google Closure Tools 中的 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;
};

有人可以解释为什么 this._dictionary 不能有 @private JsDoc 吗?谢谢!

最佳答案

Closure Linter 旨在强制执行 Google JavaScript Style Guide 。 JSDoc 标记 @private 记录如下:

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.

自 Closure Linter 版本 2.3.6 起,每当成员被注释为 @private 而没有尾随下划线时,都会发出错误“成员 不能有 @private JsDoc”。

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

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

关于javascript - 为什么是 "Member must not have @private JsDoc"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11642252/

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