-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TS2416 with typescript 5.6 when using disposable lib #60145
Comments
It's generally a bad idea to use As we must update the lib types to support the evolution of the language, we must sometimes break compatibility from version to version. We have, on occasion, made features available in the language to assist with transitional changes from version to version, such as In the case of typedoc, they may need to either use 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(): ReturnType<Map<K, V>["entries"]>;
keys(): ReturnType<Map<K, V>["keys"]>;
values(): ReturnType<Map<K, V>["values"]>;
[Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]>;
} In the meantime, you should be able to work around this issue by using |
You can also work around this by adding a module augmentation to your code that introduces overloads that make the type compatible: declare module "typedoc/dist/lib/utils/map" {
interface StableKeyMap<K extends { getStableKey(): string; }, V> {
entries(): MapIterator<[K, V]>;
keys(): MapIterator<K>;
values(): MapIterator<V>;
[Symbol.iterator](): MapIterator<[K, V]>;
}
} Take care, however, that these methods in |
It looks like this is being tracked by TypeStrong/typedoc#2747. |
π 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,
π Actual behavior
There are several errors complaining incompatibility between
IterableIterator
andMapIterator
, one of them is like,π 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 aboutSymbol.disposable
:The text was updated successfully, but these errors were encountered: