Function: formatCurrency()
function formatCurrency(value: CurrencyInput, locale?: string): string;Defined in: shared/datatable/lib/format.ts:161
Format a monetary value given in MAJOR units — dollars, not cents.
1234.56 renders $1,234.56.
The sibling formatCentsRange takes MINOR units, as its name says. The
asymmetry is deliberate and pinned by tests, but it is a footgun: everything
else in the package is integer cents (UDS formatMoney, CurrencyInput, the
insights minorUnits path), so a caller who assumes cents here gets a figure
100× too large, silently.
Switching this to cents would produce 100×-wrong output in every consumer that did not migrate. If the convention ever moves, rename the function with it so no call site keeps compiling against the old meaning.
Parameters
| Parameter | Type | Default value |
|---|---|---|
value | CurrencyInput | undefined |
locale | string | DEFAULT_LOCALE |
Returns
string