Closed rfgamaral closed 3 years ago
I think it's a little too late to answer your question, but the issue could be with the memGot not having a type defined. Instead it can be often improved as below.
const memGot = (url:string, opts: GotOptions<string>) => pMemoize(() => got(url, opts), {maxAge: 6000});
It would be better to follow this syntax as the options passed to the got function can be varying and this will help in keeping the code clean.
Also the advantage of using p-memoize over mem is explained here. Answered best of my knowledge. Correct me if I'm wrong.
What am I missing to get
p-memoize
properly working with TypeScript?
Nothing, probably the types are wrong.
What exactly is the advantage of
p-memoize
overmem
for using withgot
?
No advantage unless you're using cachePromiseRejection
. p-memoize
is a duplicate module and just wraps mem
to add that option.
Also the advantage of using p-memoize over mem is explained here.
Nothing there mentions p-memoize
; all of that also applies to p-memoize
For anyone else having TS issues with p-memoize, after reading this: "No advantage unless you're using cachePromiseRejection
" and realizing that I'm not using that feature, I switched to mem
and TS issues disappeared.
I've followed the example in the
README.md
but I get this:However, replacing
p-memoize
withmem
works just fine in TypeScript without any issues.This leads me to two questions:
p-memoize
properly working with TypeScript?p-memoize
overmem
for using withgot
?