javascript - Big.js Typescript 错误:当提供 `--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
};