dotansimha / graphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
https://the-guild.dev/graphql/yoga-server
MIT License
8.25k stars 574 forks source link

Compatibility with TS 5.6 #3442

Open benasher44 opened 1 month ago

benasher44 commented 1 month ago

Describe the bug

The build fails compiling with TS 5.6:

node_modules/graphql-yoga/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 '() => MapIterator<K>'.
    Call signature return types 'Generator<K, void, unknown>' and 'MapIterator<K>' 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>;

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

  1. Install graphql-yoga 5.x
  2. Run tsc with TS 5.6

Expected behavior

Compiles successfully

Screenshots or Videos

No response

Platform

Additional context

lru-cache v10.x doesn't seem to be compatible with TS 5.6, but lru-cache v11 seems to be fine. Upgrading would require dropping support for node less 20 though, so this would require graphql-yoga to go to v6. Maybe it's time?

tplorts commented 1 week ago

we can get our project to compile by adding this to our tsconfig

"strictBuiltinIteratorReturn": false,

but would prefer to keep that setting enabled if possible.

sstoneloveall commented 2 days ago

Same issue. The tsconfig setting "strictBuiltinIteratorReturn": false prevents the error, but it would be nice to keep it enabled. FYI https://github.com/isaacs/node-lru-cache/issues/354 lru cache issue has been recently fixed in the source library so hopefully the dependency can be fixed.