Skip to content

Commit bd132ea

Browse files
committed
Allow Infinity
1 parent 9c727be commit bd132ea

File tree

5 files changed

+147
-26
lines changed

5 files changed

+147
-26
lines changed

src/lib/es2023.intl.d.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ declare namespace Intl {
2727
source: "startRange" | "endRange" | "shared";
2828
}
2929

30+
type StringNumericLiteral = `${number}` | "Infinity" | "-Infinity" | "+Infinity";
31+
3032
interface NumberFormat {
31-
format(value: number | bigint | `${number}`): string;
32-
formatToParts(value: number | bigint | `${number}`): NumberFormatPart[];
33-
formatRange(start: number | bigint | `${number}`, end: number | bigint | `${number}`): string;
34-
formatRangeToParts(start: number | bigint | `${number}`, end: number | bigint | `${number}`): NumberRangeFormatPart[];
33+
format(value: number | bigint | StringNumericLiteral): string;
34+
formatToParts(value: number | bigint | StringNumericLiteral): NumberFormatPart[];
35+
formatRange(start: number | bigint | StringNumericLiteral, end: number | bigint | StringNumericLiteral): string;
36+
formatRangeToParts(start: number | bigint | StringNumericLiteral, end: number | bigint | StringNumericLiteral): NumberRangeFormatPart[];
3537
}
3638
}

tests/baselines/reference/intlNumberFormatES2023.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0];
2828
new Intl.NumberFormat('en-GB').format('-12.3E-4');
2929
new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8');
3030
new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
31+
new Intl.NumberFormat('en-GB').format('Infinity');
32+
new Intl.NumberFormat('en-GB').format('-Infinity');
33+
new Intl.NumberFormat('en-GB').format('+Infinity');
3134

3235

3336
//// [intlNumberFormatES2023.js]
@@ -53,3 +56,6 @@ new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0];
5356
new Intl.NumberFormat('en-GB').format('-12.3E-4');
5457
new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8');
5558
new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
59+
new Intl.NumberFormat('en-GB').format('Infinity');
60+
new Intl.NumberFormat('en-GB').format('-Infinity');
61+
new Intl.NumberFormat('en-GB').format('+Infinity');

tests/baselines/reference/intlNumberFormatES2023.symbols

+21
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,24 @@ new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8');
109109
>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.es2023.intl.d.ts, --, --))
110110
>formatRangeToParts : Symbol(Intl.NumberFormat.formatRangeToParts, Decl(lib.es2023.intl.d.ts, --, --))
111111

112+
new Intl.NumberFormat('en-GB').format('Infinity');
113+
>new Intl.NumberFormat('en-GB').format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
114+
>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.es2023.intl.d.ts, --, --))
115+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 5 more)
116+
>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.es2023.intl.d.ts, --, --))
117+
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
118+
119+
new Intl.NumberFormat('en-GB').format('-Infinity');
120+
>new Intl.NumberFormat('en-GB').format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
121+
>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.es2023.intl.d.ts, --, --))
122+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 5 more)
123+
>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.es2023.intl.d.ts, --, --))
124+
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
125+
126+
new Intl.NumberFormat('en-GB').format('+Infinity');
127+
>new Intl.NumberFormat('en-GB').format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
128+
>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.es2023.intl.d.ts, --, --))
129+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2016.intl.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --) ... and 5 more)
130+
>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.es2023.intl.d.ts, --, --))
131+
>format : Symbol(Intl.NumberFormat.format, Decl(lib.es5.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2023.intl.d.ts, --, --))
132+

0 commit comments

Comments
 (0)