Adding a string to a number or boolean works:
math.add("2", 4) // 6
math.add("2", true) // 3
Whilst trying to add a string and a bignumber, fraction, or complex number fails:
math.add("2", math.bignumber(4)) // TypeError: Unexpected type of argument in function add (expected: number, actual: BigNumber, index: 1)
math.add("2", math.fraction(2, 4)) // TypeError: Unexpected type of argument in function add (expected: number, actual: Fraction, index: 1)
math.add("2", math.complex(2, 0)) // TypeError: Unexpected type of argument in function add (expected: number, actual: Complex, index: 1)
Reason is that there are a few conversion definitions missing: string to bignumber, string to fraction, string to complex, and maybe a few more. See code.
Adding a string to a number or boolean works:
Whilst trying to add a string and a bignumber, fraction, or complex number fails:
Reason is that there are a few conversion definitions missing: string to bignumber, string to fraction, string to complex, and maybe a few more. See code.