From c97310681da0fab68ac17fb100fbfcb249dec402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= <9092381+Renegade334@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:12:53 +0000 Subject: [PATCH] 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> --- packages/collection/src/collection.ts | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/collection/src/collection.ts b/packages/collection/src/collection.ts index 5fa11cb1e..8f842ef68 100644 --- a/packages/collection/src/collection.ts +++ b/packages/collection/src/collection.ts @@ -1,14 +1,4 @@ /* eslint-disable no-param-reassign */ -/** - * @internal - */ -export interface CollectionConstructor { - new (): Collection; - new (entries?: readonly (readonly [Key, Value])[] | null): Collection; - new (iterable: Iterable): Collection; - readonly prototype: Collection; - readonly [Symbol.species]: CollectionConstructor; -} /** * Represents an immutable version of a collection @@ -19,13 +9,13 @@ export type ReadonlyCollection = Omit< > & ReadonlyMap; -/** - * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself - * - * @internal - */ -export interface Collection extends Map { - constructor: CollectionConstructor; +export interface Collection { + /** + * Ambient declaration to allow `this.constructor[@@species]` in class methods. + * + * @internal + */ + constructor: typeof Collection & { readonly [Symbol.species]: typeof Collection }; } /**