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

hypot function typescript definition seems wrong #3125

Closed
silentmissile opened this issue Jan 7, 2024 · 2 comments
Closed

hypot function typescript definition seems wrong #3125

silentmissile opened this issue Jan 7, 2024 · 2 comments

Comments

@silentmissile
Copy link

in typescript definition of mathjs, there is hypot function definition

hypot<T extends (number | BigNumber)[]>(...args: T[]): T

in this definition T can't be number, T has to be number[], and this function would return number[], this result is not our expectation

so I think it actually means:

hypot<T extends (number | BigNumber)>(...args: T[]): T

@josdejong
Copy link
Owner

Thanks for bringing this up.

Function hypot can be both:

math.hypot(a, b, ...)
math.hypot([a, b, c, ...])

See code: https://github.com/josdejong/mathjs/blob/develop/src/function/arithmetic/hypot.js#L25-L28

We should reflect that in the type definitions. Anyone able to help improve the definitions?

Hudsxn added a commit to Hudsxn/mathjs that referenced this issue Jan 29, 2024
josdejong pushed a commit that referenced this issue Jan 31, 2024
* Addressed silentmissile's comment in #3125

* Added method overload to index.d.ts, have to revert commit due to changes to package-lock.json with using npm install to run the unit tests & lint tests
@josdejong
Copy link
Owner

Fixed now in v12.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants