josdejong/mathjs

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

Open

#2,286 创建于 2021年7月14日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)JavaScript (1,298 fork)batch import
help wantedtypescript

仓库指标

Star
 (13,832 star)
PR 合并指标
 (30 天内没有已合并 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)

贡献者指南