-
-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: improve type declarations for utils/group-in
#1448
Conversation
@Planeshifter @kgryte Please review it |
@Planeshifter @kgryte Please review it. |
utils/group-in
@@ -108,7 +108,8 @@ type Indicator = Nullary | Unary | Binary; | |||
* var out = groupIn( obj, indicator ); | |||
* // e.g., returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } | |||
*/ | |||
declare function groupIn( obj: any, indicator: Indicator ): any; | |||
declare function groupIn<T, K>(obj: T, indicator: (v: T) => K): { [key: string]: K[] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These declarations do not look correct. The values returned by the indicator function are, TMK, not what is in the output arrays.
Furthermore, this PR should seek to enhance the existing Indicator
definition, not simply ignore it as you have done here.
@@ -181,8 +182,7 @@ declare function groupIn( obj: any, indicator: Indicator ): any; | |||
* var out = groupIn( obj, opts, indicator ); | |||
* // e.g., returns { 'b': [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], 'f': [ [ 'c', 'foo' ] ] } | |||
*/ | |||
declare function groupIn( obj: any, options: Options, indicator: Indicator ): any; | |||
|
|||
declare function groupIn<T, K>(obj: T, options: Options, indicator: (v: T) => K): any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to avoid any
, you could use overloads based on the returns
option value.
This pull request has been automatically closed because it has been inactive for an extended period after changes were requested. If you still wish to pursue this contribution, feel free to reopen the pull request or submit a new one. We appreciate your interest in contributing to stdlib! |
Resolves #1084
Description
This pull request:
Related Issues
This pull request:
@stdlib/utils/group-in
#1084Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers