Skip to content

Commit

Permalink
fix: #3180 fix type definitions of function add and multiply to a…
Browse files Browse the repository at this point in the history
…llow

  more than two arguments
  • Loading branch information
josdejong committed Apr 3, 2024
1 parent 02f195f commit 2e427ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# unpublished changes since 12.4.1

- Fix: #3180 fix type definitions of functions `add` and `multiply` to allow
more than two arguments.
- Docs: correct the docs about `traverse` returning void (#3177).
Thanks @rohildshah.

Expand Down
4 changes: 4 additions & 0 deletions test/typescript-tests/testTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Basic usage examples
math.pow(m2by2, 2)
const angle = 0.2
math.add(math.pow(math.sin(angle), 2), math.pow(math.cos(angle), 2))
math.add(2, 3, 4)
math.add(2, 3, math.bignumber(4))
math.multiply(2, 3, 4)
math.multiply(2, 3, math.bignumber(4))

// std and variance check

Expand Down
4 changes: 4 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,9 @@ export interface MathJsInstance extends MathJsFactory {
* @returns Sum of x and y
*/
add<T extends MathType>(x: T, y: T): T
add<T extends MathType>(...values: T[]): T
add(x: MathType, y: MathType): MathType
add(...values: MathType[]): MathType

/**
* Calculate the cubic root of a value.
Expand Down Expand Up @@ -1283,6 +1285,8 @@ export interface MathJsInstance extends MathJsFactory {
multiply(x: Unit, y: Unit): Unit
multiply(x: number, y: number): number
multiply(x: MathType, y: MathType): MathType
multiply<T extends MathType>(...values: T[]): T
multiply(...values: MathType[]): MathType

/**
* Calculate the norm of a number, vector or matrix. The second
Expand Down

0 comments on commit 2e427ec

Please sign in to comment.