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

@param

タグタイプ: ブロックタグ

TSDocの標準化: core

構文

  • @param NAME - DESCRIPTION

@paramタグは、関数またはメソッドのパラメーターをドキュメントするために使用されます。 @paramタグの後にパラメーター名、ハイフン、説明が続きます。ブロックタグであるため、@paramは次のブロックタグまでのすべてのコメントテキストを含むTSDocセクションを紹介します。

注: JSDocのバージョン@paramタグでは、オプションでタイプ情報を中括弧で指定できます。たとえば:

// NOT SUPPORTED BY API EXTRACTOR

/**
* @param {string} somebody - Somebody's name.
*/
function sayHello(somebody) {
alert('Hello ' + somebody);
}

API Extractorはこの{string}表記をサポートしません。その文法は複雑で、実装されているタイプシステムは、TypeScriptに比べてかなり基本的なものだからです。TypeScriptのソースコードの場合、パラメーターの型情報はすでにコードに完全に表現されているため、ドキュメントコメントで表現しようとしても冗長になります。

使用例

/** @public */
export class Statistics {
/**
* Returns the average of two numbers.
*
* @remarks
* This method is part of the {@link core-library#Statistics | Statistics subsystem}.
*
* @param x - The first input number
* @param y - The second input number
* @returns The arithmetic mean of `x` and `y`
*/
public static getAverage(x: number, y: number): number {
return (x + y) / 2.0;
}
}

こちらも参照