-
Notifications
You must be signed in to change notification settings - Fork 27
chore: add dht selectors and validators #94
Conversation
0d3d327
to
839959e
Compare
839959e
to
d0df910
Compare
d0df910
to
b2cdea0
Compare
new(): EventEmitter; | ||
} | ||
export type SelectFn = function (Uint8Array, Uint8Array[]): number | ||
export type ValidateFn = function (Uint8Array, Uint8Array): Promise<void> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add a typedef to /src/index.js
like:
/**
* @typedef {import('./types').SelectFn} SelectFn
* @typedef {import('./types').ValidateFn} ValidateFn
* @typedef {import('./types').DhtSelectors} DhtSelectors
* @typedef {import('./types').DhtValidators} DhtValidators
*/
then you can use them from other modules like:
/**
* @typedef {import('libp2p-interfaces').SelectFn} SelectFn
*/
otherwise you have to do:
/**
* @typedef {import('libp2p-interfaces/src/types').SelectFn} SelectFn
*/
Which is ok, but needs the typesVersions
hack and prevents you from moving that file in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing:
src/validator.js:15:19 - error TS2306: File '/Users/vsantos/work/pl/gh/libp2p/js-libp2p-record/node_modules/libp2p-interfaces/dist/src/index.d.ts' is not a module.
15 * @param {import('libp2p-interfaces').DhtValidators} validators
After generated
type SelectFn = import('./types').SelectFn;
type ValidateFn = import('./types').ValidateFn;
type DhtSelectors = import('./types').DhtSelectors;
type DhtValidators = import('./types').DhtValidators;
//# sourceMappingURL=index.d.ts.map
I could not easily work around this issue, so I reverted to the original solution for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion inline, not a blocker
Adds dht selectors and validators here to be used across the board easily.
Also removes unecessary EventEmitter types, as this was already fixed