Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(format): extend native Intl options #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export const enum CurrencySign {
* @public
* The options that can be passed to {@link format} or {@link unsafeFormat} to tweak to formatting.
*/
export interface MonetaryValueFormatOptions {
export interface MonetaryValueFormatOptions
extends Omit<
Intl.NumberFormatOptions,
'style' | 'currency' | 'minimumFractionDigits' | 'maximumFractionDigits'
> {
/**
* The locale matching algorithm to use.
* For more information, see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
Expand All @@ -90,10 +94,6 @@ export interface MonetaryValueFormatOptions {
* Determines how to display the currency part of the string.
*/
currencyDisplay?: CurrencyDisplay;
/**
* Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.
*/
useGrouping?: boolean;
/**
* @alpha
* Determines in which situation the sign should be displayed.
Expand Down Expand Up @@ -165,9 +165,7 @@ export function nativeFormat<C extends string>(
unsafeToNumber(monetaryValue),
locales,
{
localeMatcher: formatOptions.localeMatcher,
currencyDisplay: formatOptions.currencyDisplay,
useGrouping: formatOptions.useGrouping,
...formatOptions,
style: 'currency',
currency: monetaryValue.currency,
minimumFractionDigits: monetaryValue.precision,
Expand Down