josdejong / josdejong/mathjs

Type annotation for mathjs.unit is not correct

Open
#3,637 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
In [index.d.ts](https://github.com/josdejong/mathjs/blob/4d08f7ff1fb7b901cab280fea49938540603e411/types/index.d.ts#L924), the unit function is annotated as `unit(value: MathNumericType, unit?: string): Unit`. However, according to the documentation, the valid calls are

```
math.unit(value: number, valuelessUnit: string) : Unit
math.unit(value: number, valuelessUnit: Unit) : Unit
math.unit(unit: string) : Unit
math.unit(unit: Unit) : Unit
```

I believe the unit function should be typed as `unit(value: MathNumericType, unit?: string | Unit): Unit`

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.