0

我有一个使用 Mathjs 的 TypeScript 项目。

这就是我定义 mathjs 实例的方式

import { all, create } from "mathjs";
export const mathjs = create(all, { number: "Fraction" });
export const { parse } = mathjs;
// @ts-ignore
export const replacer = mathjs.replacer;

这就是我使用它的方式

import { mathjs } from "../mathjs";
import { MathNode } from "mathjs";

export const isMathEqual = (a: any, b: any) => {
  let as: MathNode;
  let bs: MathNode;

  // apply sort if we are not in a relationalNode
  as = a.conditionals ? normalize(a) : sort(normalize(a));

  bs = b.conditionals ? normalize(b) : sort(normalize(b));
... }

我想使用MathNodetype 而不是anyin const isMathEqual,但是当我通过 a 时,RelationalNode我得到一个错误“条件在 MathNode 类型上不存在”。我能做些什么呢?

4

0 回答 0