【发布时间】:2021-09-25 04:51:39
【问题描述】:
您好,我遇到了覆盖类型的问题
我想从一个库中覆盖一个类型,该类型将一个属性添加到另一个库的类型中,该行是:https://github.com/discord-akairo/discord-akairo/blob/e092ce4e0c9e749418601476bcd054a30a262785/src/index.d.ts#L14
在我的代码中我这样声明:
declare module 'discord.js' {
export interface Message {
util?: KopekUtil;
}
}
KopekUtil 正在扩展 CommandUtil,我得到的错误是:
TS2717: Subsequent property declarations must have the same type. Property 'util' must be of type 'CommandUtil', but here has type 'KopekUtil'. index.d.ts(16, 13): 'util' was also declared here.
【问题讨论】:
-
您是否尝试扩展您的 KopekUtil 类,以便它实现 CommandUtil?例如interface KopekUtil extends CommandUtil{ //扩展方法或属性 }。如有疑问,请发布您的 KopekUtil 课程,以便我了解您的意图
-
gist.github.com/ShockTr/5bdc131dec04dd8a3984946d6a978736 这是我的 KopekUtil 课程
标签: node.js typescript discord discord.js typescript-typings