处理错误的包装类型

时间:2018-05-15 09:55:17

标签: typescript

我使用的是一个JavaScript库,它通过NPM和TypeScript类型一起发布。不幸的是,这些打字往往是错误的。 PullRequests需要花费很长时间才能合并,因此我正在寻找一个更好的选择,我可以在我的本地项目中修复这些类型。

我尝试在/src/types/package-name.d.ts中创建自己的类型,然后添加了

"paths": {
    "*": [
        "node_modules/*",
        "src/types/*"
    ]
},

到我的tsconfig.json。不幸的是,似乎包装内部的打字仍然是首选,我无法覆盖它们。

示例代码:

node_modules /包/ index.d.ts:

declare module 'discord.js-commando' {
  export class XY {
    addZ(): number; // WRONG! <-- it should be number | string
  }
}

我的/src/types/package-fix.d.ts:

declare module 'discord.js-commando' {
  export class XY {
    addZ(): number | string; // Right! <-- Still does not work :(
  }
}

我的问题:

如何修复随包一起提供的包类型定义?

0 个答案:

没有答案
相关问题