number.toFixed causes "Error: don't know how to turn this value into a node"
- Dominant language
- JavaScript
- Stars
- 4.4k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I wrote this sample code:
```ts
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`
Contributor guide
Research direction
No repository file or test is named. Reproduce the failure with the TypeScript sample and the babel-minify version used indirectly by @storybook/core@5.1.9, then trace the toFixed inlining path. Done means the sample compiles without the node-conversion error and a regression test covers amount.toFixed(2).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100