Commit 17c55a9
fix(@formatjs/intl-durationformat): pass BigDecimal directly to NumberFormat
Addresses review feedback on #6466: the previous version round-tripped
the BigDecimal through `.toString() as ${number}` before formatToParts,
which is conceptually lossy and required a hand-waving cast. NumberFormat
(V3) coerces non-primitive inputs through ToPrimitive → toString and
parses the result as a StringNumericLiteral, so passing the BigDecimal
straight through gives the same exact-decimal semantics with no cast.
- Widen `createMemoizedNumberFormat` to a `NumberFormatLike` that types
`format`/`formatToParts` as accepting BigDecimal (and string).
- Drop the `${number}` cast at the formatToParts call.
- Revert the `ES2023.Intl` lib addition — no longer needed now that the
call site doesn't depend on the V3 string overload signature.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 1429e8f commit 17c55a9
4 files changed
Lines changed: 21 additions & 8 deletions
File tree
- packages
- ecma402-abstract
- intl-durationformat/abstract
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | | - | |
| 160 | + | |
148 | 161 | | |
149 | | - | |
| 162 | + | |
150 | 163 | | |
151 | 164 | | |
152 | 165 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
0 commit comments