diff --git a/types/mathjs/index.d.ts b/types/mathjs/index.d.ts index 71f89b3e1a..8b133c29f7 100644 --- a/types/mathjs/index.d.ts +++ b/types/mathjs/index.d.ts @@ -1345,7 +1345,7 @@ declare namespace math { * the Matrix/array being traversed. * @returns Transformed map of x */ - map(x: Matrix | MathArray, callback: ((value: any, index: any, matrix: Matrix | MathArray) => Matrix | MathArray)): Matrix | MathArray; + map(x: Matrix | MathArray, callback: ((value: any, index: any, matrix: Matrix | MathArray) => MathType | string)): Matrix | MathArray; /** * Create a matrix filled with ones. The created matrix can have one or diff --git a/types/mathjs/mathjs-tests.ts b/types/mathjs/mathjs-tests.ts index 7c3dfaec35..38aedea488 100644 --- a/types/mathjs/mathjs-tests.ts +++ b/types/mathjs/mathjs-tests.ts @@ -270,6 +270,13 @@ Matrices examples math.range('2:-1:-3'); math.factorial(math.range('1:6')); } + + // map matrix + { + math.map([1, 2, 3], function(value) { + return value * value; + }); // returns [1, 4, 9] + } } /*