如何在jsdoc函数参数中指定Date对象?

Bat*_* G. 8 javascript jsdoc ecmascript-6

/**
 * 
 * @param {?} date 
 */
function diffDays (date){

  var utcThis = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds());
  var utcOther = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());

  return (utcThis - utcOther) / 86400000;
};
Run Code Online (Sandbox Code Playgroud)

我在 jsdoc 文档中找不到任何关于内置 Date 对象的文档。在 params 列表中指定日期类型的推荐方法是什么。

小智 7

我是这样写的

/**
 *  @param {Date} date - input date
 */
Run Code Online (Sandbox Code Playgroud)

  • 它显示智能感知中的“any”类型,这不是我要找的东西。 (3认同)