4

I am using big.js in a Typescript react app and the following code

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

gives the below errors when using RoundingMode

Cannot access ambient const enums when the '--isolatedModules' flag is provided.ts(2748)

Why does this error occurs, and is there a way to fix this? Thank you!

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
};
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

0 Answers0