【发布时间】:2020-02-25 05:38:16
【问题描述】:
TLDR;我该如何翻译:
/** @return {((function(...[*]=))|{})[]} */
进入自己的@typedef。
我正在尝试使用 JSDoc 在 @typedef 中正确定义从我的函数返回的值,如果不使用 @return {((function(...[*]=))|{})[]} * 替换我的类型,我无法正确定义它。
我目前拥有的:
/**
* @typedef {Array} MyType
* @property {function(): void} submit - Submit
* @property {Object} state - FetchResult
*/
/** @return {MyType} */
function fooBar() {
return [() => {}, {}];
}
导致警告:
Returned expression type ((function(...[*]=)) | {})[] is not assignable to type MyType
将 fooBar() 的 JSDoc 替换为:
/** @return {((function(...[*]=))|{})[]} */
导致正确的行为。
感谢您的帮助,
【问题讨论】:
标签: javascript jsdoc