From fb8907762d0bbba0ec3d5db43bd6799b597b52b2 Mon Sep 17 00:00:00 2001 From: utkarsh raj Date: Sun, 25 Feb 2024 11:18:57 +0530 Subject: [PATCH 1/2] refactor: improve type declarations for group function using generics refactor: add type constraint for group labels in group function declaration --- .../@stdlib/utils/group/docs/types/index.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts index 0009b6a58389..ba26db1f992c 100644 --- a/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts @@ -51,7 +51,10 @@ interface Options { * var out = group( arr, groups ); * // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } */ -declare function group( collection: Collection, groups: Collection ): any; +declare function group( + collection: Collection, + groups: Collection +): { [key: string]: Collection }; /** * Groups values as arrays associated with distinct keys. @@ -89,7 +92,11 @@ declare function group( collection: Collection, groups: Collection ): any; * var out = group( arr, opts, groups ); * // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } */ -declare function group( collection: Collection, options: Options, groups: Collection ): any; +declare function group( + collection: Collection, + options: Options, + groups: Collection +): { [key: string]: Collection }; // EXPORTS // From 12ecbc58e5807ab02ef4910c3bc3f8b4419cb291 Mon Sep 17 00:00:00 2001 From: utkarsh raj Date: Sat, 2 Mar 2024 08:09:18 +0530 Subject: [PATCH 2/2] refactor: changed group type declaration --- .../@stdlib/utils/group/docs/types/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts index ba26db1f992c..1489f85c5e49 100644 --- a/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts @@ -51,10 +51,10 @@ interface Options { * var out = group( arr, groups ); * // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } */ -declare function group( +declare function group( collection: Collection, groups: Collection -): { [key: string]: Collection }; +): { [key in K]: Collection }; /** * Groups values as arrays associated with distinct keys. @@ -92,11 +92,11 @@ declare function group( * var out = group( arr, opts, groups ); * // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } */ -declare function group( +declare function group( collection: Collection, options: Options, groups: Collection -): { [key: string]: Collection }; +): { [key in K]: Collection }; // EXPORTS //