josdejong/mathjs

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

開放

#2,286 建立於 2021年7月14日

 (3 則留言) (0 個反應) (0 位負責人)JavaScript (1,314 個分叉)batch import
help wantedtypescript

倉庫指標

星標
 (15,065 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

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

貢獻者指南