This means that if you pass a fn returning Promise<MyType>, and you need to use your own custom cache, you need to pass e.g. Map<string, {data: MyType, maxAge: number}>, which is incorrect; the cache will store Promise<MyType> in the data field of each cache entry.
Currently the only way to compile code using p-memoize and a custom cache is to type the custom cache values as any.
By using the same type for the return type of fn and the data entries, the error is resolved.
The current interface in index.d.ts:
This means that if you pass a
fn
returningPromise<MyType>
, and you need to use your own custom cache, you need to pass e.g.Map<string, {data: MyType, maxAge: number}>
, which is incorrect; the cache will storePromise<MyType>
in thedata
field of each cache entry.Currently the only way to compile code using p-memoize and a custom cache is to type the custom cache values as
any
.By using the same type for the return type of
fn
and thedata
entries, the error is resolved.Fixed by https://github.com/sindresorhus/p-memoize/pull/27