@param
标签类型:块标签
TSDoc 标准化:核心
语法
@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 提取器不支持这种
{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;
}
}