@example
タグの種類: ブロック タグ
TSDoc 標準化: 拡張
API の使用方法を示す例として提示する必要があるドキュメント セクションを示します。コード サンプルを含めることができます。
使用例
/**
* Adds two numbers together.
*
* @remarks
* Use this function to perform example addition.
*
* @example
* Here's a simple example:
* ```
* // Prints "2":
* console.log(add(1,1));
* ```
*
* @example
* Here's an example with negative numbers:
* ```
* // Prints "0":
* console.log(add(1,-1));
* ```
*
* @param x - the first number to add
* @param y - the second number to add
* @public
*/
export function add(x: number, y: number): number {
return x + y;
}
API ドキュメンターは、example セクションに自動的に番号を付けます。
出力は次のようになりますadd() 関数
2 つの数字を足します。export declare function add(x: number, y: number): number;
シグネチャnumber
パラメータ パラメータ タイプ 説明 x
number 加算する最初の数字 x
y
x
加算する 2 番目の数字返り値
remarksこの関数を使用して、例の加算を実行します。
// Prints "2":
console.log(add(1,1));例 1負の値の例を次に示します
// Prints "0":
console.log(add(1,-1));