Skip to content

Commit 0822116

Browse files
snowystingerOrta Theroxortasandersn
authored
Add missing currencyDisplay to resolved number format options (microsoft#44006)
* Add missing currencyDisplay to resolved number format options * Move declaration to es2020 * Update es2020.intl.d.ts * Fix bad merge Co-authored-by: Orta Therox <[email protected]> Co-authored-by: Orta Therox <[email protected]> Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent 2635102 commit 0822116

10 files changed

+77
-14
lines changed

src/lib/es2020.intl.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ declare namespace Intl {
203203
signDisplay?: "auto" | "never" | "always" | "exceptZero" | undefined;
204204
unit?: string | undefined;
205205
unitDisplay?: "short" | "long" | "narrow" | undefined;
206+
currencyDisplay?: string | undefined;
207+
currencySign?: string | undefined;
206208
}
207209

208210
interface ResolvedNumberFormatOptions {
@@ -211,6 +213,8 @@ declare namespace Intl {
211213
signDisplay?: "auto" | "never" | "always" | "exceptZero";
212214
unit?: string;
213215
unitDisplay?: "short" | "long" | "narrow";
216+
currencyDisplay?: string;
217+
currencySign?: string;
214218
}
215219

216220
interface DateTimeFormatOptions {

src/lib/es5.d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -4355,7 +4355,6 @@ declare namespace Intl {
43554355
localeMatcher?: string | undefined;
43564356
style?: string | undefined;
43574357
currency?: string | undefined;
4358-
currencyDisplay?: string | undefined;
43594358
currencySign?: string | undefined;
43604359
useGrouping?: boolean | undefined;
43614360
minimumIntegerDigits?: number | undefined;
@@ -4370,7 +4369,6 @@ declare namespace Intl {
43704369
numberingSystem: string;
43714370
style: string;
43724371
currency?: string;
4373-
currencyDisplay?: string;
43744372
minimumIntegerDigits: number;
43754373
minimumFractionDigits: number;
43764374
maximumFractionDigits: number;

tests/baselines/reference/numberFormatCurrencySign.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD',
33

44

55
//// [numberFormatCurrencySign.js]
6-
var str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
6+
"use strict";
7+
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
=== tests/cases/compiler/numberFormatCurrencySign.ts ===
1+
=== tests/cases/conformance/es2020/numberFormatCurrencySign.ts ===
22
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
33
>str : Symbol(str, Decl(numberFormatCurrencySign.ts, 0, 5))
4-
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --))
5-
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
6-
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --))
7-
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
4+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
5+
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
6+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more)
7+
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
88
>style : Symbol(style, Decl(numberFormatCurrencySign.ts, 0, 44))
99
>currency : Symbol(currency, Decl(numberFormatCurrencySign.ts, 0, 63))
1010
>currencySign : Symbol(currencySign, Decl(numberFormatCurrencySign.ts, 0, 80))
11-
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --))
11+
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
1212

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
=== tests/cases/compiler/numberFormatCurrencySign.ts ===
1+
=== tests/cases/conformance/es2020/numberFormatCurrencySign.ts ===
22
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
33
>str : string
44
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999) : string
5-
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : (value: number) => string
5+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format : { (value: number): string; (value: number | bigint): string; }
66
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }) : Intl.NumberFormat
7-
>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[]; }
7+
>Intl.NumberFormat : { (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; }
88
>Intl : typeof Intl
9-
>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[]; }
9+
>NumberFormat : { (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; }
1010
>'en-NZ' : "en-NZ"
1111
>{ style: 'currency', currency: 'NZD', currencySign: 'accounting' } : { style: string; currency: string; currencySign: string; }
1212
>style : string
@@ -15,6 +15,6 @@ const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD',
1515
>'NZD' : "NZD"
1616
>currencySign : string
1717
>'accounting' : "accounting"
18-
>format : (value: number) => string
18+
>format : { (value: number): string; (value: number | bigint): string; }
1919
>999999 : 999999
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [numberFormatCurrencySignResolved.ts]
2+
const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions();
3+
const currencySign = options.currencySign;
4+
5+
6+
//// [numberFormatCurrencySignResolved.js]
7+
"use strict";
8+
const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions();
9+
const currencySign = options.currencySign;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/conformance/es2020/numberFormatCurrencySignResolved.ts ===
2+
const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions();
3+
>options : Symbol(options, Decl(numberFormatCurrencySignResolved.ts, 0, 5))
4+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions : Symbol(Intl.NumberFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
5+
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
6+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more)
7+
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
8+
>style : Symbol(style, Decl(numberFormatCurrencySignResolved.ts, 0, 48))
9+
>currency : Symbol(currency, Decl(numberFormatCurrencySignResolved.ts, 0, 67))
10+
>currencySign : Symbol(currencySign, Decl(numberFormatCurrencySignResolved.ts, 0, 84))
11+
>resolvedOptions : Symbol(Intl.NumberFormat.resolvedOptions, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
12+
13+
const currencySign = options.currencySign;
14+
>currencySign : Symbol(currencySign, Decl(numberFormatCurrencySignResolved.ts, 1, 5))
15+
>options.currencySign : Symbol(Intl.ResolvedNumberFormatOptions.currencySign, Decl(lib.es2020.intl.d.ts, --, --))
16+
>options : Symbol(options, Decl(numberFormatCurrencySignResolved.ts, 0, 5))
17+
>currencySign : Symbol(Intl.ResolvedNumberFormatOptions.currencySign, Decl(lib.es2020.intl.d.ts, --, --))
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/conformance/es2020/numberFormatCurrencySignResolved.ts ===
2+
const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions();
3+
>options : Intl.ResolvedNumberFormatOptions
4+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions() : Intl.ResolvedNumberFormatOptions
5+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions : { (): Intl.ResolvedNumberFormatOptions; (): Intl.ResolvedNumberFormatOptions; }
6+
>new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }) : Intl.NumberFormat
7+
>Intl.NumberFormat : { (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; }
8+
>Intl : typeof Intl
9+
>NumberFormat : { (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat; supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[]; }
10+
>'en-NZ' : "en-NZ"
11+
>{ style: 'currency', currency: 'NZD', currencySign: 'accounting' } : { style: string; currency: string; currencySign: string; }
12+
>style : string
13+
>'currency' : "currency"
14+
>currency : string
15+
>'NZD' : "NZD"
16+
>currencySign : string
17+
>'accounting' : "accounting"
18+
>resolvedOptions : { (): Intl.ResolvedNumberFormatOptions; (): Intl.ResolvedNumberFormatOptions; }
19+
20+
const currencySign = options.currencySign;
21+
>currencySign : string | undefined
22+
>options.currencySign : string | undefined
23+
>options : Intl.ResolvedNumberFormatOptions
24+
>currencySign : string | undefined
25+
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
// @target: esnext
2+
// @lib: esnext
3+
// @strict: true
14
const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: esnext
2+
// @lib: esnext
3+
// @strict: true
4+
const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions();
5+
const currencySign = options.currencySign;

0 commit comments

Comments
 (0)