mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
fix(43799): Support bigint type for Intl.NumberFormat.formatToParts (#44015)
* Add bigint support for formatToParts * Add tests for Intl.NumberFormat.formatToParts * Cleanup test * Fix EOL symbols * Update baseline test
This commit is contained in:
2
src/lib/esnext.intl.d.ts
vendored
2
src/lib/esnext.intl.d.ts
vendored
@@ -7,6 +7,6 @@ declare namespace Intl {
|
||||
}
|
||||
|
||||
interface NumberFormat {
|
||||
formatToParts(number?: number): NumberFormatPart[];
|
||||
formatToParts(number?: number | bigint): NumberFormatPart[];
|
||||
}
|
||||
}
|
||||
|
||||
13
tests/baselines/reference/formatToPartsBigInt.js
Normal file
13
tests/baselines/reference/formatToPartsBigInt.js
Normal file
@@ -0,0 +1,13 @@
|
||||
//// [formatToPartsBigInt.ts]
|
||||
// Intl.NumberFormat.formatToParts should support bigInt
|
||||
|
||||
// Test Intl methods with new parameter type
|
||||
new Intl.NumberFormat("fr").formatToParts(3000n);
|
||||
new Intl.NumberFormat("fr").formatToParts(BigInt(123));
|
||||
|
||||
|
||||
//// [formatToPartsBigInt.js]
|
||||
// Intl.NumberFormat.formatToParts should support bigInt
|
||||
// Test Intl methods with new parameter type
|
||||
new Intl.NumberFormat("fr").formatToParts(3000n);
|
||||
new Intl.NumberFormat("fr").formatToParts(BigInt(123));
|
||||
19
tests/baselines/reference/formatToPartsBigInt.symbols
Normal file
19
tests/baselines/reference/formatToPartsBigInt.symbols
Normal file
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/formatToPartsBigInt.ts ===
|
||||
// Intl.NumberFormat.formatToParts should support bigInt
|
||||
|
||||
// Test Intl methods with new parameter type
|
||||
new Intl.NumberFormat("fr").formatToParts(3000n);
|
||||
>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>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 1 more)
|
||||
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --))
|
||||
|
||||
new Intl.NumberFormat("fr").formatToParts(BigInt(123));
|
||||
>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>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 1 more)
|
||||
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.esnext.intl.d.ts, --, --))
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
28
tests/baselines/reference/formatToPartsBigInt.types
Normal file
28
tests/baselines/reference/formatToPartsBigInt.types
Normal file
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/formatToPartsBigInt.ts ===
|
||||
// Intl.NumberFormat.formatToParts should support bigInt
|
||||
|
||||
// Test Intl methods with new parameter type
|
||||
new Intl.NumberFormat("fr").formatToParts(3000n);
|
||||
>new Intl.NumberFormat("fr").formatToParts(3000n) : Intl.NumberFormatPart[]
|
||||
>new Intl.NumberFormat("fr").formatToParts : (number?: number | bigint) => Intl.NumberFormatPart[]
|
||||
>new Intl.NumberFormat("fr") : 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[]; }
|
||||
>"fr" : "fr"
|
||||
>formatToParts : (number?: number | bigint) => Intl.NumberFormatPart[]
|
||||
>3000n : 3000n
|
||||
|
||||
new Intl.NumberFormat("fr").formatToParts(BigInt(123));
|
||||
>new Intl.NumberFormat("fr").formatToParts(BigInt(123)) : Intl.NumberFormatPart[]
|
||||
>new Intl.NumberFormat("fr").formatToParts : (number?: number | bigint) => Intl.NumberFormatPart[]
|
||||
>new Intl.NumberFormat("fr") : 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[]; }
|
||||
>"fr" : "fr"
|
||||
>formatToParts : (number?: number | bigint) => Intl.NumberFormatPart[]
|
||||
>BigInt(123) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>123 : 123
|
||||
|
||||
7
tests/cases/compiler/formatToPartsBigInt.ts
Normal file
7
tests/cases/compiler/formatToPartsBigInt.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// @target: esnext
|
||||
|
||||
// Intl.NumberFormat.formatToParts should support bigInt
|
||||
|
||||
// Test Intl methods with new parameter type
|
||||
new Intl.NumberFormat("fr").formatToParts(3000n);
|
||||
new Intl.NumberFormat("fr").formatToParts(BigInt(123));
|
||||
Reference in New Issue
Block a user