如何使用内联JSDoc指示参数是可选的? [英] How to indicate param is optional using inline JSDoc?
本文介绍了如何使用内联JSDoc指示参数是可选的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据 @param 的JSDoc Wiki,您可以使用
According to the JSDoc wiki for @param you can indicate a @param is optional using
/**
@param {String} [name]
*/
function getPerson(name) {
}
,您可以使用
function getPerson(/**String*/ name) {
}
我可以像下面这样组合它们,效果很好.
And I can combine them like the following, which works ok.
/**
@param [name]
*/
function getPerson(/**String*/name) {
}
但是我想知道是否有可能在可能的情况下内联完成所有操作.
But I would like to know if there is a way to do it all inline if possible.
推荐答案
I found a way to do this using Google Closure Compiler type expressions. You put an equals sign after the type like so:
function test(/**String=*/arg) {}
这篇关于如何使用内联JSDoc指示参数是可选的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文