我正在使用一个 npm 模块,该模块在DefinitelyTyped/DefinitelyTyped github 存储库中进行了声明,但该模块的类型不完整。
我已经提出了拉取请求来获取缺失的声明,但是在其被接受之前,我需要有一种方法来暂时扩展不完整的声明。
理想情况下,我希望能够在我的项目根目录中有一个 temporaryTypings.d.ts
文件,我可以在其中为我遇到的每种情况添加声明。
最佳答案
您可以从非 DefinitelyTyped 源安装定义,例如您的 DT 分支:
# (this example is taken from https://www.npmjs.com/package/typings )
# If you need a specific commit from github.
$ typings install d3=github:DefinitelyTyped/DefinitelyTyped/d3/d3.d.ts#1c05872e7811235f43780b8b596bfd26fe8e7760
npm
因为 typescript 2 也可以从特定的 git 存储库安装模块。
关于typescript - 如何扩展类型声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39844981/