josdejong / josdejong/mathjs

Property 'Unit' does not exist on type 'MathJsStatic'. Did you mean 'unit'? error in Typescript

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

Description

When creating the following code in Typescript

```
import { MathJsStatic, create, all, MathType } from 'mathjs';
const math: MathJsStatic = create(all, {}) as MathJsStatic;

math.createUnit('cells'); // works perfectly
math.Unit; // results in: Property 'Unit' does not exist on type 'MathJsStatic'. Did you mean 'unit'?
```

It looks like Unit isn't properly part of the new MathJS typescript definitions or it's not linking correctly.

if I replace the line above with `window['testing'] = math` then the Unit is in fact present.

![image](https://user-images.githubusercontent.com/3583395/125630805-534a4a21-0107-4396-ad7a-66120e0f919c.png)

Edit: I am running mathjs 9.4.4 without `@types/mathjs` (relying on the built-in type definitions)

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.