Rush Stackショップブログイベント
メインコンテンツにスキップ

@defaultValue

タグの種類: ブロックタグ

TSDocの標準化: 拡張

このタグは、値が明示的に割り当てられていない場合、フィールドまたはプロパティの既定値をドキュメント化するために使用されます。このタグは、クラスまたはインターフェイスのメンバーであるフィールドまたはプロパティでのみ使用してください。

ブロックタグとして、@defaultValueは、次のブロックタグまでコメントテキスト全体を含むTSDocセクションを導入します。このコンテンツは「値テキスト」と呼ばれます。値テキストは、さまざまな形式にすることができます。たとえば

  • リテラル値。例: @defaultValue 3
  • コードスパン。例:
    @defaultValue true
  • 複数行にまたがる可能性のある任意のリッチテキスト。例:
    @defaultValue {@link Widget}オブジェクトのインスタンス

したがって、ドキュメンテーションテンプレートは、値テキストが完全にコードで構成されていると想定しないでください。

使用例

export enum WarningStyle {
DialogBox,
StatusMessage,
LogOnly
}

export interface IWarningOptions {
/**
* Determines how the warning will be displayed.
*
* @remarks
* See {@link WarningStyle| the WarningStyle enum} for more details.
*
* @defaultValue `WarningStyle.DialogBox`
*/
warningStyle: WarningStyle;

/**
* Whether the warning can interrupt a user's current activity.
*
* @defaultValue
* The default is `true` unless {@link WarningStyle.StatusMessage}
* was requested.
*/
cancellable?: boolean;

message: string;
}

関連項目