ae-setter-with-docs
"属性的文档注释___必须出现在 getter 上,而不是 setter 上。
备注
API 提取器将属性 getter/setter 对建模为单个 API 项目。getter 是主要声明,setter 被视为“辅助”签名。只有 getter 可以有文档注释。如果在 setter 上找到了文档注释,则 API 提取器将报告 ae-setter-with-docs
错误。
示例
/**
* Represents a book from the catalog.
* @public
*/
export class Book {
private _title: string = 'untitled';
/**
* Gets the title of the book.
*/
public get title(): string {
return this._title;
}
/**
* Sets the title of the book.
*/
// Error: (ae-setter-with-docs) The doc comment for the property "title" must appear
// on the getter, not the setter.
public set title(value: string) {
this._title = value;
}
}
如何修复
从 setter 中删除文档注释。在 getter 的文档注释中描述这两个选项
/**
* Represents a book from the catalog.
* @public
*/
export class Book {
private _title: string = 'untitled';
/**
* Gets or sets the title of the book.
*/
public get title(): string {
return this._title;
}
public set title(value: string) {
this._title = value;
}
}