[英]jsDoc : How do I make the @return type of my method the type of a local variable from it?
I'm making a javascript project and I want to make it as clean as possible, and for that I'm using jsDoc at the top of my methods.我正在制作一个 javascript 项目,我想让它尽可能干净,为此我在我的方法顶部使用 jsDoc。 For one of them, I would like to know if it's possible to specify as a return type the type of a local variable ?
对于其中之一,我想知道是否可以将局部变量的类型指定为返回类型?
Like this :像这样 :
/**
* Add a component to the gameObject
* @param {Function} component to add
* @return {comp.constructor.name}
*/
addComponent(component){
let comp = eval("new Tzu." + component.name + "({gameObject : this});");
this.behaviors.push(comp);
return comp;
}
I want the @return to be the type of comp我希望 @return 是comp的类型
Of course the line 4 is completely wrong当然第4行是完全错误的
Thanks !谢谢 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.