You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* eslint-disable @typescript-eslint/no-explicit-any */interfaceReadonlyMapConstructor{new(): ReadonlyMap<any,any>;new<K,V>(entries?: ReadonlyArray<readonly[K,V]>|Iterable<readonly[K,V]>|null,): ReadonlyMap<K,V>;readonlyprototype: ReadonlyMap<any,any>;}/** An alias for the `Map` constructor that returns a read-only map. */exportconstReadonlyMap=MapasReadonlyMapConstructor;
It produces the following output in a ".d.ts" file:
interfaceReadonlyMapConstructor{new(): ReadonlyMap$1<any,any>;new<K,V>(entries?: ReadonlyArray<readonly[K,V]>|Iterable<readonly[K,V]>|null): ReadonlyMap$1<K,V>;readonlyprototype: ReadonlyMap$1<any,any>;}/** An alias for the `Map` constructor that returns a read-only map. */declareconstReadonlyMap$1: ReadonlyMapConstructor;
There are two problems with this:
If we import the library and do const FOO = new ReadonlyMap<string, string>(); and we mouse over FOO, we see that the type is ReadonlyMap$1<K, V> instead of ReadonlyMap<K, V>. That's a problem. In other words, if we are exporting helper types to consumers, we don't want those types mangled.
More importantly, the "@typescript-eslint/no-unsafe-assignment" rule flags this as an any value, because the ".d.ts" has errors in it.
The text was updated successfully, but these errors were encountered:
Zamiell
changed the title
types are bugged
types inside .d.ts files are bugged
Dec 15, 2023
Environment
Reproduction
If you use unbuild on the following code:
It produces the following output in a ".d.ts" file:
There are two problems with this:
const FOO = new ReadonlyMap<string, string>();
and we mouse overFOO
, we see that the type isReadonlyMap$1<K, V>
instead ofReadonlyMap<K, V>
. That's a problem. In other words, if we are exporting helper types to consumers, we don't want those types mangled.any
value, because the ".d.ts" has errors in it.The text was updated successfully, but these errors were encountered: