Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRUCache seems to incorrectly implement Map<K, V> #332

Open
vacavaca opened this issue Mar 26, 2024 · 1 comment
Open

LRUCache seems to incorrectly implement Map<K, V> #332

vacavaca opened this issue Mar 26, 2024 · 1 comment

Comments

@vacavaca
Copy link

vacavaca commented Mar 26, 2024

typescript: 5.4.3
node: 21.7.1
lru-cache: 10.2.0
@types/node: 20.11.30

Got the following error from inside the lru-cache when running tsc on my project, could it be something on my side? Earlier versions, before implementing Map, are not affected.

> tsc

node_modules/lru-cache/dist/commonjs/index.d.ts:762:5 - error TS2416: Property 'forEach' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any) => void' is not assignable to type '(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void'.
    Types of parameters 'fn' and 'callbackfn' are incompatible.
      Types of parameters 'map' and 'self' are incompatible.
        Property 'toJSON' is missing in type 'LRUCache<K, V, FC>' but required in type 'Map<K, V>'.

762     forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
        ~~~~~~~

  ../../node_modules/@types/core-js/index.d.ts:68:5
    68     toJSON(): any;
           ~~~~~~~~~~~~~~
    'toJSON' is declared here.
@isaacs
Copy link
Owner

isaacs commented Mar 26, 2024

So it needs a toJSON method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants