在函数的@param 和@returns 中使用相同的泛型类型
Use of same generic type in @param and @returns for a function
如何用JSDoc
注释一个function
接受和相同类型returns对象?类似于以下内容:
/**
* 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
}
如何用JSDoc
注释一个function
接受和相同类型returns对象?类似于以下内容:
/**
* 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
}