Skip to content

TS2416 with typescript 5.6 when using disposable libΒ #60145

Closed
@jameslan

Description

@jameslan

πŸ”Ž Search Terms

disposable ts2416

πŸ•— Version & Regression Information

⏯ 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"],

Metadata

Metadata

Assignees

Labels

ExternalRelates to another program, environment, or user action which we cannot control.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions