鉴于以下结构:
BigBoss.specify({
/**
* EsDoc, will not show me
*/
val:'val',
/**
* EsDoc, will not show me
*/
fn:function(){
return 'fn';
}
// lots more members I want to documenent in EsDoc
});
这也失败了:
const bigspec = {
/**
* EsDoc, will not show me
*/
val:'val',
/**
* EsDoc, will not show me
*/
fn:function(){
return 'fn';
}
// lots more members I want to documenent in EsDoc
};
我将使用模块级类来解决这个问题:
class WantsToBePojoSomeday { // assume will never inherit
// assume no constructor params
/**
* EsDoc now documents me
*/
val='val';
/**
* EsDoc now documents me
*/
fn(){
return '';
}
}
const AsPojo=function(klass){
const inst=new klass;
const o={};
for (var i in inst) {
o[i]=inst[i];
}
return o;
}
现在呼叫变为:
BigBoss.specify(AsPojo(WantsToBePojoSomeday));
我想要的是安全地#39;扩展Function.prototype以使调用成为:
BigBoss.specify(WantsToBePojoSomeday._Pojo);
欢迎提出其他建议。