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

TS 5.6.0-beta compilation error in a project consuming lru-cache #348

Closed
jeremymeng opened this issue Aug 12, 2024 · 2 comments
Closed

TS 5.6.0-beta compilation error in a project consuming lru-cache #348

jeremymeng opened this issue Aug 12, 2024 · 2 comments

Comments

@jeremymeng
Copy link

jeremymeng commented Aug 12, 2024

typescript 5.5.4 works fine, but 5.6.0-beta gives the following error. Repro project: https://github.com/jeremymeng/lru-cache-ts-5.6.0-beta.
.

node_modules/lru-cache/dist/commonjs/index.d.ts:973:5 - error TS2416: Property 'entries' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '() => Generator<[K, V], void, unknown>' is not assignable to type '() => BuiltinIterator<[K, V], undefined, any>'.
    Call signature return types 'Generator<[K, V], void, unknown>' and 'BuiltinIterator<[K, V], undefined, any>' are incompatible.
      The types returned by 'next(...)' are incompatible between these types.
        Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
          Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
            Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
              Type 'void' is not assignable to type 'undefined'.

973     entries(): Generator<[K, V], void, unknown>;
        ~~~~~~~

node_modules/lru-cache/dist/commonjs/index.d.ts:985:5 - error TS2416: Property 'keys' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '() => Generator<K, void, unknown>' is not assignable to type '() => BuiltinIterator<K, undefined, any>'.
    Call signature return types 'Generator<K, void, unknown>' and 'BuiltinIterator<K, undefined, any>' are incompatible.
      The types returned by 'next(...)' are incompatible between these types.
        Type 'IteratorResult<K, void>' is not assignable to type 'IteratorResult<K, undefined>'.
          Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<K, undefined>'.
            Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
              Type 'void' is not assignable to type 'undefined'.

985     keys(): Generator<K, void, unknown>;
        ~~~~

node_modules/lru-cache/dist/commonjs/index.d.ts:997:5 - error TS2416: Property 'values' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '() => Generator<V, void, unknown>' is not assignable to type '() => BuiltinIterator<V, undefined, any>'.
    Call signature return types 'Generator<V, void, unknown>' and 'BuiltinIterator<V, undefined, any>' are incompatible.
      The types returned by 'next(...)' are incompatible between these types.
        Type 'IteratorResult<V, void>' is not assignable to type 'IteratorResult<V, undefined>'.
          Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<V, undefined>'.
            Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
              Type 'void' is not assignable to type 'undefined'.

997     values(): Generator<V, void, unknown>;
        ~~~~~~

node_modules/lru-cache/dist/commonjs/index.d.ts:1009:5 - error TS2416: Property '[Symbol.iterator]' in type 'LRUCache<K, V, FC>' is not assignable to the same property in base type 'Map<K, V>'.
  Type '() => Generator<[K, V], void, unknown>' is not assignable to type '() => BuiltinIterator<[K, V], undefined, any>'.
    Call signature return types 'Generator<[K, V], void, unknown>' and 'BuiltinIterator<[K, V], undefined, any>' are incompatible.
      The types returned by 'next(...)' are incompatible between these types.
        Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
          Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
            Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
              Type 'void' is not assignable to type 'undefined'.

1009     [Symbol.iterator](): Generator<[K, V], void, unknown>;
         ~~~~~~~~~~~~~~~~~

node_modules/lru-cache/dist/commonjs/index.d.ts:1032: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.
        Type 'LRUCache<K, V, FC>' is not assignable to type 'Map<K, V>'.
          The types returned by 'entries().next(...)' are incompatible between these types.
            Type 'IteratorResult<[K, V], void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
              Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorResult<[K, V], undefined>'.
                Type 'IteratorReturnResult<void>' is not assignable to type 'IteratorReturnResult<undefined>'.
                  Type 'void' is not assignable to type 'undefined'.

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


Found 5 errors in the same file, starting at: node_modules/lru-cache/dist/commonjs/index.d.ts:973
@isaacs
Copy link
Owner

isaacs commented Aug 13, 2024

This project builds fine, as you say. Use skipLibCheck: true and don't worry about what your libs are doing. It's fine.

@isaacs isaacs closed this as completed Aug 13, 2024
@mrginglymus
Copy link

mrginglymus commented Aug 19, 2024

A more differently focussed workaround, until lru-cache supports 5.6, is to disable the new strictBuiltinIteratorReturn option introduced in microsoft/TypeScript#58243

hiddentao added a commit to gemstation/gemforge that referenced this issue Sep 10, 2024
hiddentao added a commit to gemstation/gemforge that referenced this issue Sep 11, 2024
* fix: ensure public methods are named to external in IDiamondProxy - see #41

* build: try to fix build failing due to typescript issue

see isaacs/node-lru-cache#348
jeremymeng added a commit to Azure/azure-sdk-for-js that referenced this issue Sep 20, 2024
***NO_CI***

- replace version to "~5.6.2"
- rush update
- add `"skipLibCheck": true` for several packages that are affected by vitest-dev/vitest#4688

- [formrecognizer] help TypeScript to understand with more explicit type

- [schema-registry-{avro,json}] skip lib check due to lru-cache issue with the Iterator TReturn change

isaacs/node-lru-cache#348
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

3 participants