-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Use data type map instead of overloads #1317
Conversation
lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/array/typed-complex/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/array/zeros-like/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
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.
@Planeshifter All in all, this is looking good. And the changes certainly condense declarations and better preserve type information. In general, I think we need to rename the type maps and do so using an existing naming convention. Personally, I don't have an issue with verbosity, given auto-complete and aliasing.
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@kgryte Feedback has been addressed, PR is now ready for another look! |
lib/node_modules/@stdlib/array/empty-like/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
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.
Thanks for the updates, @Planeshifter. Left a few comments concerning when to use DataTypeMap
vs when to use NumericAndGenericDataTypeMap
.
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.
LGTM. Thanks, @Planeshifter! Let's get this in. Any further updates can be addressed in follow-up PRs.
Description
This pull request:
dtype
parameter and returning an array of the respective type to not use function overloads but instead a type map. This allows for cutting down on the resulting bloat and will make the codebase more maintainable, as adding support for a new data type would simply require updating the type map inside@stdlib/types
.One potential concern is Intellisense showing opaque type information, but I argue that this is a non-issue if we have appropriate TSDoc comments, as is the case in this example where we enumerate the possible values in the comment.
Furthermore, the current overloading strategy also is not ideal from an Intellisense point of view, since it forces users to manually step through the available overloads to see what inputs are allowed:
(there is a 1/12 stepper button in the bottom left to toggle between the overloads; covered by the Copilot interface for some reason but usually it's fully visible...)
Related Issues
No.
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers