diff --git a/src/index.js b/src/index.js index 4ed09b98ca..1f60627c7f 100644 --- a/src/index.js +++ b/src/index.js @@ -102,7 +102,7 @@ const { updateSelfPeerRecord } = require('./record/utils') * @property {PeerRoutingModule[]} [peerRouting] * @property {ContentRoutingModule[]} [contentRouting] * @property {Object} [dht] - * @property {Pubsub} [pubsub] + * @property {{new(...args: any[]): Pubsub}} [pubsub] * @property {Protector} [connProtector] * * @typedef {Object} Libp2pOptions diff --git a/src/pubsub-adapter.js b/src/pubsub-adapter.js index e965ab5c4b..8ccbf90f48 100644 --- a/src/pubsub-adapter.js +++ b/src/pubsub-adapter.js @@ -7,12 +7,13 @@ */ /** - * @param {import("libp2p-interfaces/src/pubsub")} PubsubRouter + * @param {{new(...args: any[]): PubsubRouter}} PubsubRouter * @param {import('.')} libp2p * @param {{ enabled: boolean; } & import(".").PubsubLocalOptions & import("libp2p-interfaces/src/pubsub").PubsubOptions} options */ function pubsubAdapter (PubsubRouter, libp2p, options) { - // @ts-ignore Pubsub constructor type not defined + /** @type {PubsubRouter & { _subscribeAdapter: PubsubRouter['subscribe'], _unsubscribeAdapter: PubsubRouter['unsubscribe'] }} */ + // @ts-ignore we set the extra _subscribeAdapter and _unsubscribeAdapter properties afterwards const pubsub = new PubsubRouter(libp2p, options) pubsub._subscribeAdapter = pubsub.subscribe pubsub._unsubscribeAdapter = pubsub.unsubscribe