From 956893d23b70158bb923a3f359891d3e461f8af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Paris?= Date: Thu, 5 Aug 2021 16:23:34 +0200 Subject: [PATCH] feat(format): extend native Intl options --- src/formatting.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/formatting.ts b/src/formatting.ts index 957a71a..f26bd0c 100644 --- a/src/formatting.ts +++ b/src/formatting.ts @@ -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). @@ -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. @@ -165,9 +165,7 @@ export function nativeFormat( unsafeToNumber(monetaryValue), locales, { - localeMatcher: formatOptions.localeMatcher, - currencyDisplay: formatOptions.currencyDisplay, - useGrouping: formatOptions.useGrouping, + ...formatOptions, style: 'currency', currency: monetaryValue.currency, minimumFractionDigits: monetaryValue.precision,