Skip to content

Commit b9586ab

Browse files
committed
Merge branch 'types/toTex-optional-options' of https://github.com/goodproblems/mathjs into goodproblems-types/toTex-optional-options
# Conflicts: # types/index.d.ts # types/index.ts
2 parents 13a3d4c + e56cf85 commit b9586ab

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,6 @@ Sinan <[email protected]>
188188
189189
Divya Yeruva <[email protected]>
190190
simlaticak <[email protected]>
191+
Matt Vague <[email protected]>
191192

192193
# Generated by tools/update-authors.js

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,7 @@ declare namespace math {
31813181
* @param object An object with functions to be imported.
31823182
* @param options An object with import options.
31833183
*/
3184-
import(object: ImportObject | ImportObject[], options: ImportOptions): void
3184+
import(object: ImportObject | ImportObject[], options?: ImportOptions): void
31853185
}
31863186

31873187
/*************************************************************************

types/index.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,65 @@ declare module 'mathjs' {
894894

895895
math.testFun()
896896

897-
const _a = math.value * 2
897+
expectTypeOf(math.testFun()).toMatchTypeOf<number>()
898+
899+
expectTypeOf(
900+
math.import({
901+
myvalue: 42,
902+
myFunc: (name: string) => `myFunc ${name}`,
903+
})
904+
).toMatchTypeOf<void>()
905+
906+
expectTypeOf(
907+
math.import(
908+
{
909+
myvalue: 42,
910+
myFunc: (name: string) => `myFunc ${name}`,
911+
},
912+
{
913+
override: true,
914+
}
915+
)
916+
).toMatchTypeOf<void>()
917+
918+
expectTypeOf(
919+
math.import(
920+
{
921+
myvalue2: 42,
922+
},
923+
{
924+
silent: true,
925+
}
926+
)
927+
).toMatchTypeOf<void>()
928+
929+
expectTypeOf(
930+
math.import(
931+
{
932+
myvalue3: 42,
933+
},
934+
{
935+
wrap: true,
936+
}
937+
)
938+
).toMatchTypeOf<void>()
939+
940+
expectTypeOf(
941+
math.import({
942+
myvalue4: 42,
943+
})
944+
).toMatchTypeOf<void>()
945+
946+
expectTypeOf(
947+
math.import([
948+
{
949+
myvalue5: 42,
950+
},
951+
{
952+
myFunc2: (name: string) => `myFunc2 ${name}`,
953+
},
954+
])
955+
).toMatchTypeOf<void>()
898956
}
899957

900958
/*
@@ -1174,3 +1232,20 @@ Probability function examples
11741232
math.lgamma(math.complex(1.5, -1.5))
11751233
).toMatchTypeOf<math.Complex>()
11761234
}
1235+
1236+
/*
1237+
toTex examples
1238+
*/
1239+
1240+
{
1241+
const math = create(all, {})
1242+
1243+
expectTypeOf(math.parse('a/b').toTex()).toMatchTypeOf<string>()
1244+
1245+
// TODO add proper types for toTex options
1246+
expectTypeOf(
1247+
math.parse('a/b').toTex({
1248+
a: '123',
1249+
})
1250+
).toMatchTypeOf<string>()
1251+
}

0 commit comments

Comments
 (0)