我对Google Closure Compiler(GCC)非常陌生。我不知道如何将参数显示为可选的...
以下是我的部分代码:
/**
* @param {string} name The event name
* @param {Date} date1 The start date (If alone, the single date) of the event
* @param {Date} date2 The end date of the event
*/
function getEventLink (name,date1,date2) {
// code here
}
我希望
date2
是可选的...我在Closure Compiler的页面上找到了一些有用的信息,但我没有看到可选项...是否可能?如果是,我该如何实现?我尝试过:
/**
* @param {string} name The event name
* @param {Date} date1 The start date (If alone, the single date) of the event
* @param {Date|undefined} date2 The end date of the event
*/
function getEventLink (name,date1,date2) {
// code here
}
此外,使用
null
代替undefined
,但似乎都不起作用...
null
或undefined
等。 - SamathingamajigGCC
是否可以使参数成为“可选的”吗? - Jacob Hornbeck