是否可以在 JSDoc 中指定函数覆盖?
Is it possible to specify function overrides in JSDoc?
我要记录的内容示例如下:
/**
* @return {boolean}
*/
Contains(rectangle_or_x, y, tolerance) {
if (rectangle_or_x instanceof Rectangle) { return ((rectangle_or_x.X >= this._x) && (rectangle_or_x.Y >= this._y) && (rectangle_or_x.Right <= this._right) && (rectangle_or_x.Bottom <= this._bottom)); }
if ((tolerance === undefined) || (tolerance === null) || (!Rectangle._isNumeric(tolerance))) {
if ((rectangle_or_x < this._x) || (y < this._y) || (rectangle_or_x > this._right) || (y > this._bottom)) { return (false); }
} else if (((rectangle_or_x + tolerance) < this._x) || ((y + tolerance) < this._y) || ((rectangle_or_x - tolerance) > this._right) || ((y - tolerance) > this._bottom)) { return (false); }
return (true);
}
其中有 3 个可能的调用,其中一个可以忽略,因为它基于可选的 tolerance
参数,但两个基数以排他方式重叠:
Contains(Rectangle rectangle_or_x)
Contains(Number rectangle_or_x, Number y[, Number tolerance])
考虑到不同的类型(我知道 JavaScript 是无类型的,但就示例而言,涉及确定的类型)是否可以创建单独的 @param
值集使用 JSDoc(主要用于 WebStorm 中的智能感知,但理论上也用于在线文档。)
无法指定独占的 JSDoc 集。
您可以尝试类似的方法:
/**
* @param {Rectangle|Number} rectangle_or_x
* @param {Number=} y
* @param {Number=} tolerance
* @return {boolean}
*/
Contains(rectangle_or_x, y, tolerance) {}
我要记录的内容示例如下:
/**
* @return {boolean}
*/
Contains(rectangle_or_x, y, tolerance) {
if (rectangle_or_x instanceof Rectangle) { return ((rectangle_or_x.X >= this._x) && (rectangle_or_x.Y >= this._y) && (rectangle_or_x.Right <= this._right) && (rectangle_or_x.Bottom <= this._bottom)); }
if ((tolerance === undefined) || (tolerance === null) || (!Rectangle._isNumeric(tolerance))) {
if ((rectangle_or_x < this._x) || (y < this._y) || (rectangle_or_x > this._right) || (y > this._bottom)) { return (false); }
} else if (((rectangle_or_x + tolerance) < this._x) || ((y + tolerance) < this._y) || ((rectangle_or_x - tolerance) > this._right) || ((y - tolerance) > this._bottom)) { return (false); }
return (true);
}
其中有 3 个可能的调用,其中一个可以忽略,因为它基于可选的 tolerance
参数,但两个基数以排他方式重叠:
Contains(Rectangle rectangle_or_x)
Contains(Number rectangle_or_x, Number y[, Number tolerance])
考虑到不同的类型(我知道 JavaScript 是无类型的,但就示例而言,涉及确定的类型)是否可以创建单独的 @param
值集使用 JSDoc(主要用于 WebStorm 中的智能感知,但理论上也用于在线文档。)
无法指定独占的 JSDoc 集。
您可以尝试类似的方法:
/**
* @param {Rectangle|Number} rectangle_or_x
* @param {Number=} y
* @param {Number=} tolerance
* @return {boolean}
*/
Contains(rectangle_or_x, y, tolerance) {}