-
-
Notifications
You must be signed in to change notification settings - Fork 364
Closed
Description
TypeScript 5.6 (currently in RC) includes some changes to builtin iterator types, which causes several of the iterator-returning methods of LRUCache to be unassignable to its implements Map<K, V>
. For details, see microsoft/TypeScript#58243. To reproduce:
npm i typescript@rc
npm i @types/node@latest # currently installed @types/node breaks for same reason
tsc --noEmit
src/index.ts:1704:4 - 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 '() => MapIterator<[K, V]>'.
Call signature return types 'Generator<[K, V], void, unknown>' and 'MapIterator<[K, V]>' 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'.
1704 *entries() {
~~~~~~~
src/index.ts:1738:4 - 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'.
1738 *keys() {
~~~~
src/index.ts:1772:4 - 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 '() => MapIterator<V>'.
Call signature return types 'Generator<V, void, unknown>' and 'MapIterator<V>' 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'.
1772 *values() {
~~~~~~
src/index.ts:1806:3 - 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 '() => MapIterator<[K, V]>'.
Call signature return types 'Generator<[K, V], void, unknown>' and 'MapIterator<[K, V]>' 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'.
1806 [Symbol.iterator]() {
~~~~~~~~~~~~~~~~~
src/index.ts:1848:3 - 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'.
1848 forEach(
~~~~~~~
Found 5 errors in the same file, starting at: src/index.ts:1704
As an aside, I noticed that neither npm run build
nor npm test
seems to type check currently (or at least tshy isn’t reporting the type errors to the console)—is that intended?
jacob-alford
Metadata
Metadata
Assignees
Labels
No labels