types(collection): simplify ambient constructor declaration (#10549)

- deduplicates constructor definition
- removes Collection's "internal" JSDoc description block
- removes unnecessary `extends` clause

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
René
2024-11-07 11:12:53 +00:00
committed by GitHub
parent ea042458a3
commit c97310681d

View File

@@ -1,14 +1,4 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/**
* @internal
*/
export interface CollectionConstructor {
new (): Collection<unknown, unknown>;
new <Key, Value>(entries?: readonly (readonly [Key, Value])[] | null): Collection<Key, Value>;
new <Key, Value>(iterable: Iterable<readonly [Key, Value]>): Collection<Key, Value>;
readonly prototype: Collection<unknown, unknown>;
readonly [Symbol.species]: CollectionConstructor;
}
/** /**
* Represents an immutable version of a collection * Represents an immutable version of a collection
@@ -19,13 +9,13 @@ export type ReadonlyCollection<Key, Value> = Omit<
> & > &
ReadonlyMap<Key, Value>; ReadonlyMap<Key, Value>;
/** export interface Collection<Key, Value> {
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself /**
* * Ambient declaration to allow `this.constructor[@@species]` in class methods.
* @internal *
*/ * @internal
export interface Collection<Key, Value> extends Map<Key, Value> { */
constructor: CollectionConstructor; constructor: typeof Collection & { readonly [Symbol.species]: typeof Collection };
} }
/** /**