From 11bd60fc59529dc957dd50fb7816bc068d04f39c Mon Sep 17 00:00:00 2001 From: Jongsu Liam Kim Date: Fri, 2 Nov 2018 01:32:27 +0900 Subject: [PATCH] fix wrong return type of callback of map function --- types/mathjs/index.d.ts | 2 +- types/mathjs/mathjs-tests.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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] + } } /*