Big.js 打字稿错误:当提供“--isolatedModules”标志时,无法访问环境常量枚举ts(2748)

问题描述

我在 Typescript react 应用程序和以下代码中使用 big.js

const toFixedRounding = {
  [Rounding.ROUND_DOWN]: RoundingMode.RoundDown,[Rounding.ROUND_HALF_UP]: RoundingMode.RoundHalfUp,[Rounding.ROUND_UP]: RoundingMode.RoundUp,};

在使用 RoundingMode

时出现以下错误

当提供“--isolatedModules”标志时无法访问环境常量枚举。ts(2748)

为什么会出现这个错误,有没有办法解决这个问题?谢谢!

test.tsx

import JSBI from "jsbi";
import invariant from "tiny-invariant";
import _Decimal from "decimal.js-light";
import _Big,{ RoundingMode } from "big.js";
import toFormat from "toformat";

import { BigintIsh,Rounding } from "../constants";

const Decimal = toFormat(_Decimal);
const Big = toFormat(_Big);

const toSignificantRounding = {
  [Rounding.ROUND_DOWN]: Decimal.ROUND_DOWN,[Rounding.ROUND_HALF_UP]: Decimal.ROUND_HALF_UP,[Rounding.ROUND_UP]: Decimal.ROUND_UP,};

const toFixedRounding = {
  [Rounding.ROUND_DOWN]: RoundingMode.RoundDown,// <==== error occurs here
  [Rounding.ROUND_HALF_UP]: RoundingMode.RoundHalfUp,// <==== error occurs here
  [Rounding.ROUND_UP]: RoundingMode.RoundUp,// <==== error occurs here
};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)