I'm importing types from lowdb via @types/lowdb, and when using their mixins()
method to configure mixins on a store, it complains that the argument I'm passing doesn't type-match:
Argument of type 'Map<string, Function>' is not assignable to parameter of type 'Dictionary<(...args: any[]) => any>'. Index signature is missing in type 'Map<string, Function>'.ts(2345)
I assumed that the type accepted by the mixins
method was essentially a map of functions indexed with a string. So figured that Map<string, function>
would be an acceptable thing to pass it. The context:
async setupStore ({storeName, storeMixins} : {storeName: string, storeMixins: Map<string, Function>}) {
const store: LowdbSync<any> = await lowdb(new StoreMemoryAdapter(storeName))
store._.mixin(storeMixins)
}
I guess my confusion here is a lack of understanding of what Dictionary<(...args: any[]) => any>
expects in real terms. I'm unable to use the type declaration myself as it is not available to me in userland. But perhaps Map<string, Function>
is not the correct equivalent?