babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

number.toFixed causes "Error: don't know how to turn this value into a node" #958

Open xkizer opened 5 years ago

xkizer commented 5 years ago

Describe the bug

I wrote this sample code:

export function formatCurrency(amount: number, currencyCode: string): string {
  let formattedAmount = amount.toFixed(2);

  switch (currencyCode) {
    case 'EUR':
      return `€${formattedAmount}`;
    case 'USD':
      return `$${formattedAmount}`;
    default:
      return `${formattedAmount} ${currencyCode}`;
  }
}

Tried to compile the app, and got the error "Error: don't know how to turn this value into a node". On digging a little deeper, I was able to trace the bug to this package. The package apparently tried to inline toFixed and failed.

Configuration

How are you using babel-minify?

Used indirectly through @storybook/core@5.1.9

Sam-Apostel commented 4 years ago

I've ran into this too, any proposed fixes?