Skip to content

Commit e971001

Browse files
fix: improve type declarations by using generics in utils/group
PR-URL: #1375 Closes: #1086 Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 1096686 commit e971001

File tree

1 file changed

+9
-2
lines changed
  • lib/node_modules/@stdlib/utils/group/docs/types

1 file changed

+9
-2
lines changed

lib/node_modules/@stdlib/utils/group/docs/types/index.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ interface Options {
5151
* var out = group( arr, groups );
5252
* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
5353
*/
54-
declare function group( collection: Collection, groups: Collection ): any;
54+
declare function group<T, K extends PropertyKey>(
55+
collection: Collection<T>,
56+
groups: Collection<K>
57+
): { [key in K]: Collection<T> };
5558

5659
/**
5760
* Groups values as arrays associated with distinct keys.
@@ -89,7 +92,11 @@ declare function group( collection: Collection, groups: Collection ): any;
8992
* var out = group( arr, opts, groups );
9093
* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }
9194
*/
92-
declare function group( collection: Collection, options: Options, groups: Collection ): any;
95+
declare function group<T, K extends PropertyKey>(
96+
collection: Collection<T>,
97+
options: Options,
98+
groups: Collection<K>
99+
): { [key in K]: Collection<T> };
93100

94101

95102
// EXPORTS //

0 commit comments

Comments
 (0)