首先,我已阅读这个问题/答案,它不太适合我的情况。
我正在调用一个库函数,它动态创建并返回一个函数数组。然后我的模块导出这些函数,因此我希望将它们记录下来。我的代码如下所示:
import createFunctions from 'some-library'
/**
* What do I write here, to document `functionA` and `functionB`?
*/
const [functionA, functionB] = createFunctions('a', 'b');
// This doesn't seem to work:
/**
* Some docs
*/
functionA;
// This also doesn't seem to work:
/**
* Some docs
*/
export { functionA };
/**
* I don't know how this would work either
*/
export { functionA, functionB };
我不控制
createFunctions
,所以我无法在其中编写文档注释来描述返回的函数,如其他答案中所建议的。
编辑:我已经尝试过这两种方法,但它们似乎不起作用,至少 vscode 没有选择它们:
好吧,我想我已经弄清楚了。除非有人有更好的解决方案,否则这似乎是最好的解决方法:
import createFunctions from 'some-library'
const [_functionA, _functionB] = createFunctions('a', 'b');
/**
* Some docs for functionA
*/
const functionA = _functionA;
/**
* Some docs for functionB
*/
const functionB = _functionB;
// Can either export all together like this, or put the
// export statements above as part of each declaration.
export { functionA, functionB };