Closed
Description
π Search Terms
disposable ts2416
π Version & Regression Information
- This changed between versions 5.5 and 5.6
- This changed in commit or PR built-in iterators should be disposableΒ #59633
β― Playground Link
No response
π» Code
I am writing a typedoc plugin and needs to import typedoc, in its dist/lib/utils/map.d.ts(https://www.npmjs.com/package/typedoc?activeTab=code), it has the following declaration,
export declare class StableKeyMap<K extends {
getStableKey(): string;
}, V> implements Map<K, V> {
[Symbol.toStringTag]: string;
private impl;
get size(): number;
set(key: K, value: V): this;
get(key: K): V | undefined;
has(key: K): boolean;
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
entries(): IterableIterator<[K, V]>;
keys(): IterableIterator<K>;
values(): IterableIterator<V>;
[Symbol.iterator](): IterableIterator<[K, V]>;
}
π Actual behavior
There are several errors complaining incompatibility between IterableIterator
and MapIterator
, one of them is like,
node_modules/typedoc/dist/lib/utils/map.d.ts:19:5 - error TS2416: Property 'entries' in type 'StableKeyMap<K, V>' is not assignable to the same property in base type 'Map<K, V>'.
Type '() => IterableIterator<[K, V]>' is not assignable to type '() => MapIterator<[K, V]>'.
Property '[Symbol.dispose]' is missing in type 'IterableIterator<[K, V]>' but required in type 'MapIterator<[K, V]>'.
19 entries(): IterableIterator<[K, V]>;
~~~~~~~
node_modules/typescript/lib/lib.esnext.disposable.d.ts:36:5
36 [Symbol.dispose](): void;
~~~~~~~~~~~~~~~~~~~~~~~~~
'[Symbol.dispose]' is declared here.
π Expected behavior
typescript 5.5 and 5.4 pass transpilation smoothly.
Additional information about the issue
In the tsconfig.json
, I enabled disposable lib otherwise it will complain about Symbol.disposable
:
"lib": ["es2015", "dom", "esnext.disposable"],