stdlib
stdlib copied to clipboard
Use data type map instead of overloads
Description
What is the purpose of this pull request?
This pull request:
- proposes changing the TypeScript definitions for packages accepting a
dtypeparameter 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
Does this pull request have any related issues?
No.
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.
- [x] Read, understood, and followed the contributing guidelines.
@stdlib-js/reviewers