![](/img/trans.png)
[英]Passed function as param should use another param from the same call
[英]Use of same generic type in @param and @returns for a function
如何用JSDoc
注釋注釋一個接受並返回相同 類型對象的function
? 類似於以下內容:
/**
* Does some work and returns same type
* @param {T extends Object} src Source object
* @returns {T} object of the **same** type
*/
function chainFoo(src) {
// do some work
return Object.assing({}, src); // just as example
}
可能嗎?
解決方案是指定@template T
所以看起來像這樣:
/**
* Does some work and returns same type
* @template T
* @param {T} src Source object
* @returns {T} object of the **same** type
*/
function chainFoo(src) {
// do some work
return Object.assing({}, src); // just as example
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.