Add currency sign to NumberFormatOptions type (#40709)

This commit is contained in:
Mauro Bringolf
2020-10-07 01:30:09 +02:00
committed by GitHub
parent 3766be1bde
commit 48ad25d4b9
5 changed files with 40 additions and 0 deletions

1
src/lib/es5.d.ts vendored
View File

@@ -4284,6 +4284,7 @@ declare namespace Intl {
style?: string;
currency?: string;
currencyDisplay?: string;
currencySign?: string;
useGrouping?: boolean;
minimumIntegerDigits?: number;
minimumFractionDigits?: number;

View File

@@ -0,0 +1,6 @@
//// [numberFormatCurrencySign.ts]
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
//// [numberFormatCurrencySign.js]
var str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);

View File

@@ -0,0 +1,12 @@
=== tests/cases/compiler/numberFormatCurrencySign.ts ===
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
>str : Symbol(str, Decl(numberFormatCurrencySign.ts, 0, 5))
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --))
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>style : Symbol(style, Decl(numberFormatCurrencySign.ts, 0, 44))
>currency : Symbol(currency, Decl(numberFormatCurrencySign.ts, 0, 63))
>currencySign : Symbol(currencySign, Decl(numberFormatCurrencySign.ts, 0, 80))
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --))

View File

@@ -0,0 +1,20 @@
=== tests/cases/compiler/numberFormatCurrencySign.ts ===
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
>str : string
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999) : string
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : (value: number) => string
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }) : Intl.NumberFormat
>Intl.NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; }
>Intl : typeof Intl
>NumberFormat : { (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; new (locales?: string | string[], options?: Intl.NumberFormatOptions): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions): string[]; }
>'en-NZ' : "en-NZ"
>{ style: 'currency', currency: 'NZD', currencySign: 'accounting' } : { style: string; currency: string; currencySign: string; }
>style : string
>'currency' : "currency"
>currency : string
>'NZD' : "NZD"
>currencySign : string
>'accounting' : "accounting"
>format : (value: number) => string
>999999 : 999999

View File

@@ -0,0 +1 @@
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);