[英]Using an imported type in JSDoc @typedef
我正在尝试减少在指定导入类型时的重复,如下所示,但出现错误
/**
@typedef {import("../types/util")} util
@typedef {util.mapBehaviors} mapBehaviors
... lots of other typedefs based on util
*/
'util' only refers to a type, but is being used as a namespace here.
这很奇怪,因为扩展导入显式有效:
/**
@typedef {import("../types/util").mapBehaviors} mapBehaviors
... lots of other typedefs
*/
如何将@typedef
与导入的别名一起使用?
如果您仅从.d.ts
文件中导出interface
或type
,而不是function
或const
,则可能会发生这种情况。
这将起作用:
/**
@typedef {import("../types/types").util} util
@typedef {util["mapBehaviors"]} mapBehaviors
...
*/
但只有在util.d.ts
你有
export function mapBehaviors(tags: string[] | Behavior[], table: Behaviors): Behavior[]
...
代替
export interface mapBehaviors {
(tags: string[] | Behavior[], table: Behaviors): Behavior[]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.