@use JSDoc

语法

@implements {typeExpression}

概述

@implements 标记表示符号实现了接口。

@implements 标记添加到实现接口的顶级符号(例如,构造函数)。无需将 @implements 标记添加到实现的每个成员(例如,实现的实例方法)。

如果您未记录实现中的某个符号,JSDoc 会自动为此符号使用接口的文档。

示例

在以下示例中,TransparentColor 类实现了 Color 接口,并添加了 TransparentColor#rgba 方法。

使用 @implements 标记
/**
 * Interface for classes that represent a color.
 *
 * @interface
 */
function Color() {}

/**
 * Get the color as an array of red, green, and blue values, represented as
 * decimal numbers between 0 and 1.
 *
 * @returns {Array<number>} An array containing the red, green, and blue values,
 * in that order.
 */
Color.prototype.rgb = function() {
    throw new Error('not implemented');
};

/**
 * Class representing a color with transparency information.
 *
 * @class
 * @implements {Color}
 */
function TransparentColor() {}

// inherits the documentation from `Color#rgb`
TransparentColor.prototype.rgb = function() {
    // ...
};

/**
 * Get the color as an array of red, green, blue, and alpha values, represented
 * as decimal numbers between 0 and 1.
 *
 * @returns {Array<number>} An array containing the red, green, blue, and alpha
 * values, in that order.
 */
TransparentColor.prototype.rgba = function() {
    // ...
};