mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user