@readonly
タグタイプ: 修飾子
TSDoc の標準化: 拡張
この修飾子タグは、クラスまたはインターフェイスのプロパティで使用されます。タイプシグネチャが別の内容を示す場合でも、プロパティを「読み取り専用」としてドキュメント化する必要があることを示します。
この修飾子が必要なのは特別な状況に限ります。一般に、API Extractor はプロパティのタイプシグネチャを使用して、それが読み取り専用かどうかを判断します。
ただし、クラスのプロパティに例外として常に例外をスローするセッター関数がある場合、@readonly
修飾子を付けると、プロパティが読み取り専用としてドキュメント化されます。
使用例
/** @public */
export class Widget {
...
/**
* Everyday case: API Extractor will document this property as being read-only.
*/
public get x(): number {
return this._x;
}
/**
* Special case: We need to tell API Extractor to ignore the property setter.
* @readonly
*/
public get title(): string {
return this._title;
}
public set title(value: string) {
throw new Error('This property is read-only!');
}
}