【发布时间】:2018-04-09 02:43:36
【问题描述】:
我在 TypeScript 中使用队列库 Bull。它的定义是:
node_modules/@types/bull/index.d.ts
declare const Bull: {
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
// something like above
};
declare namespace Bull: {
interface Queue {}
interface Job {}
// some other non-exported interfaces
}
export = Bull
我想在我的库中合并命名空间Bull 并在另一个应用程序中使用它。
node_modules/myLib/index.d.ts
import { Queue } from 'bull'
declare namespace Bull: {
export interface Queues {}
}
export interface myInterface {
foo: Queue | Bull.Queues
}
export = Bull
myApp/foo.ts
import { Job, Queues } from 'myLib' // Error, 'myLib' has no exported member 'Job'
根据文档,namespace 是一个 GLOBAL 变量,同名的命名空间会合并它们的 EXPORTED 接口。那么,如何将命名空间 Bull 与 @types/bull 合并?谢谢!
【问题讨论】:
标签: typescript bull.js