Closed chrispanag closed 3 years ago
@aphelionz sorry for pinging you.
Does this pull request make sense for you? :)
Does this pull request make sense for you? :)
Almost! :)
Looking at the implementation, it seems that set
, put
, and del
all call orbit-db-store#_addOperation
, which then calls p-queue#add
, which returns Promise<TaskResultType>
.
I'm not super familiar with TypeScript - is the right thing to do here somehow import the TaskResultType
generic and use it in our types?
Does this pull request make sense for you? :)
Almost! :)
Looking at the implementation, it seems that
set
,put
, anddel
all callorbit-db-store#_addOperation
, which then callsp-queue#add
, which returnsPromise<TaskResultType>
.I'm not super familiar with TypeScript - is the right thing to do here somehow import the
TaskResultType
generic and use it in our types?
Actually not. Firstly, you can't import a generic type variable.
Secondly, the function's declaration is:
async add<TaskResultType>(fn: Task<TaskResultType>, options: Partial<EnqueueOptionsType> = {}): Promise<TaskResultType>
Which with type coercion would become:
async add<string>(fn: Task<string>, options: Partial<EnqueueOptionsType> = {}): Promise<string>
So the return type of the set
, put
and del
will return Promise<string>
which is exactly what we need to add to the types.
Thank you for taking the time to look into it! :)
As per the documentation the put/set/del operations of the KeyValueStore, should return a string containing the multihash of the entry.
But, in this types package, those operations return
void
.This pull request fixes those types.