josdejong / josdejong/mathjs

Improve the TypeScript definitions of functions like `number`, `bignumber`, `boolean`, and `complex` returning an array/matrix with known type of values

Open
#2,944 3 comments 0 reactions 0 assignees View on GitHub
feature typescript
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Currently the typescript definitions for Arrays and Matrices only supports number, BigNumber,Fraction or Complex

```javascript
type MathNumericType = number | BigNumber | Fraction | Complex
type MathArray = MathNumericType[] | MathNumericType[][]
type MathCollection = MathArray | Matrix
```

But there are functions, like 'number', that process Arrays with non-numeric types, but which are considered wrong by Typescript:
```javascript
let m = [true,false,'1','2','3']

//type error
let toNumber = math.chain(m).number().done() // [ 1, 0, 1, 2, 3 ]
```
Maybe adding a generic matrix/array type should solve ?

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.