josdejong / josdejong/mathjs

Functions do not recon with `config.number` when converting a string into a numeric type

Open
#3,206 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

It's a bit of an edge case, but for example:

```js
math.config({number: 'BigNumber'})
math.add('2', '3')
// results in a number with value 5, but should be a BigNumber with value 5
```

The reason is that functions like `add` do not have a signature like `add(string, string)`. Therefore, automatic conversion kicks in. The automatic conversion finds a conversion from `string -> number` that fits the bill and uses that, without reconing with the configured `config.number`. I'm not sure how a proper solution to fix this would look like, since the type conversions are static 🤔.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.