diff --git a/types/mathjs/index.d.ts b/types/mathjs/index.d.ts index 7917ce417e..e335421701 100644 --- a/types/mathjs/index.d.ts +++ b/types/mathjs/index.d.ts @@ -2578,7 +2578,8 @@ declare namespace math { * @param object An object with functions to be imported. * @param options An object with import options. */ - import(object: object | Array, options: ImportOptions); + import(object: ImportObject | ImportObject[], options: ImportOptions): void; + // TypeScript Version: 2.4 /** * It may not exists - this is _only_ for import functionality. @@ -4561,4 +4562,8 @@ declare namespace math { silent?: boolean; wrap?: boolean; } + + interface ImportObject { + [key: string]: any; + } } diff --git a/types/mathjs/mathjs-tests.ts b/types/mathjs/mathjs-tests.ts index babfa3ff37..c5eadb82a5 100644 --- a/types/mathjs/mathjs-tests.ts +++ b/types/mathjs/mathjs-tests.ts @@ -392,3 +392,21 @@ JSON serialization/deserialization const parsed = JSON.parse(stringified, math.json.reviver); parsed.bigNumber === math.bignumber('1.5'); // true } + +/* +Extend functionality with import + */ +{ + const testFun = function() { + return 5; + }; + + math.import({ + testFun, + value: 10 + }, {}); + + math.testFun(); + + const a = math.value * 2; +}