Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

soham2312
Copy link

Resolves #1084

Description

What is the purpose of this pull request?

This pull request:

  • Improved type declarations for @stdlib/utils/group-in

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@soham2312
Copy link
Author

@Planeshifter @kgryte Please review it

@soham2312 soham2312 changed the title Improved type declaration for utils/group-in refactor:Improved type declaration for utils/group-in Mar 10, 2024
@soham2312 soham2312 changed the title refactor:Improved type declaration for utils/group-in refactor: Improved type declaration for utils/group-in Mar 10, 2024
@soham2312
Copy link
Author

@Planeshifter @kgryte Please review it.

@kgryte kgryte added TypeScript Issue involves or relates to TypeScript. Needs Review A pull request which needs code review. labels Mar 17, 2024
@kgryte kgryte changed the title refactor: Improved type declaration for utils/group-in refactor: improve type declarations for utils/group-in Mar 17, 2024
@@ -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[] };
Copy link
Member

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;
Copy link
Member

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.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Mar 17, 2024
@Planeshifter Planeshifter added the autoclose: Stale Pull request which should be auto-closed as considered stale. label Oct 2, 2024
@stdlib-bot
Copy link
Contributor

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!

@stdlib-bot stdlib-bot closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoclose: Stale Pull request which should be auto-closed as considered stale. Needs Changes Pull request which needs changes before being merged. TypeScript Issue involves or relates to TypeScript.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: improve type declarations for @stdlib/utils/group-in
4 participants