szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

TS error when using QuickLRU from readme example #51

Open studentIvan opened 2 years ago

studentIvan commented 2 years ago
export const cacheable = new CacheableLookup({
  cache: new QuickLRU({ maxSize: 1000 }),
});
Type 'QuickLRU<string, EntryObject[] | Promise<EntryObject[] | undefined>>' is not assignable to type 'CacheInstance'.
  Types of property 'set' are incompatible.
    Type '(key: string, value: EntryObject[] | Promise<EntryObject[] | undefined>, options?: { maxAge?: number | undefined; } | undefined) => QuickLRU<string, EntryObject[] | Promise<...>>' is not assignable to type '(hostname: string, entries: EntryObject[], ttl: number) => TPromise<boolean | void | CacheInstance>'.
      Types of parameters 'options' and 'ttl' are incompatible.
        Type 'number' is not assignable to type '{ maxAge?: number | undefined; } | undefined'.ts(2322)
renatomariscal commented 2 years ago

What version of the libraries are you using? cacheable-lookup, quick-lru and typescript

szmarczak commented 2 years ago

Good catch!

https://github.com/szmarczak/cacheable-lookup/blob/45b18daf9f0c8406691fad81188e956641e2309d/index.d.ts#L11

    set(hostname: string, entries: EntryObject[], ttl: number): TPromise<void | boolean | this>;
+   set(hostname: string, entries: EntryObject[]): TPromise<void | boolean | this>;

I think this should work. Not tested yet.

viceice commented 2 years ago

seeing same error: image image

viceice commented 2 years ago

ok downgrade to v5 of both fixed the issue and is compatible with got v11

dontbesatisfied commented 1 year ago

i'm using 7.0.0 but it now fixed and 5.0.4 does not work.

iamchathu commented 1 month ago

This issue still exists for 7.0.0 of both packages