【问题标题】:How to specify Date object in jsdoc function parameter?如何在 jsdoc 函数参数中指定 Date 对象?
【发布时间】:2020-11-21 17:09:59
【问题描述】:
/**
 * 
 * @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;
};

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

【问题讨论】:

    标签: javascript ecmascript-6 jsdoc


    【解决方案1】:

    我是这样写的

    /**
     *  @param {Date} date - input date
     */
    

    【讨论】:

    • 它在智能感知中显示类型 any,这不是我要找的东西。
    猜你喜欢
    • 2011-09-21
    • 2013-01-14
    • 2017-11-22
    • 2020-03-11
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多