Skip to content

Commit f9612a0

Browse files
committed
Intl.NumberFormat: add ECMA-402 version 10 changes under es2023.intl
1 parent df89080 commit f9612a0

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const libEntries: [string, string][] = [
215215
["es2022.regexp", "lib.es2022.regexp.d.ts"],
216216
["es2023.array", "lib.es2023.array.d.ts"],
217217
["es2023.collection", "lib.es2023.collection.d.ts"],
218+
["es2023.intl", "lib.es2023.intl.d.ts"],
218219
["esnext.array", "lib.es2023.array.d.ts"],
219220
["esnext.collection", "lib.es2023.collection.d.ts"],
220221
["esnext.symbol", "lib.es2019.symbol.d.ts"],

src/lib/es2020.intl.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,20 @@ declare namespace Intl {
223223
): UnicodeBCP47LocaleIdentifier[];
224224
};
225225

226+
interface NumberFormatOptionsSignDisplayRegistry {
227+
auto: any;
228+
never: any;
229+
always: any;
230+
exceptZero: any;
231+
}
232+
233+
type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry;
234+
226235
interface NumberFormatOptions {
227236
numberingSystem: string | undefined;
228237
compactDisplay?: "short" | "long" | undefined;
229238
notation?: "standard" | "scientific" | "engineering" | "compact" | undefined;
230-
signDisplay?: "auto" | "never" | "always" | "exceptZero" | undefined;
239+
signDisplay?: NumberFormatOptionsSignDisplay | undefined;
231240
unit?: string | undefined;
232241
unitDisplay?: "short" | "long" | "narrow" | undefined;
233242
currencySign?: string | undefined;
@@ -236,7 +245,7 @@ declare namespace Intl {
236245
interface ResolvedNumberFormatOptions {
237246
compactDisplay?: "short" | "long";
238247
notation: "standard" | "scientific" | "engineering" | "compact";
239-
signDisplay: "auto" | "never" | "always" | "exceptZero";
248+
signDisplay: NumberFormatOptionsSignDisplay;
240249
unit?: string;
241250
unitDisplay?: "short" | "long" | "narrow";
242251
currencySign?: string;

src/lib/es2023.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/// <reference lib="es2022" />
22
/// <reference lib="es2023.array" />
33
/// <reference lib="es2023.collection" />
4+
/// <reference lib="es2023.intl" />

src/lib/es2023.intl.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
declare namespace Intl {
2+
interface NumberFormatUseGroupingRegistry {
3+
true: any;
4+
false: any;
5+
min2: any;
6+
auto: any;
7+
always: any;
8+
}
9+
10+
interface NumberFormatSignDisplayRegistry {
11+
negative: any;
12+
}
13+
14+
interface NumberFormatOptions {
15+
roundingPriority?: "auto" | "morePrecision" | "lessPrecision" | undefined;
16+
roundingIncrement?: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | undefined;
17+
roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined;
18+
trailingZeroDisplay?: "auto" | "stripIfInteger" | undefined;
19+
}
20+
21+
interface ResolvedNumberFormatOptions {
22+
roundingPriority: "auto" | "morePrecision" | "lessPrecision";
23+
roundingMode: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
24+
roundingIncrement: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000;
25+
trailingZeroDisplay: "auto" | "stripIfInteger";
26+
}
27+
}

src/lib/es5.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,12 +4409,16 @@ declare namespace Intl {
44094409

44104410
var Collator: CollatorConstructor;
44114411

4412+
interface NumberFormatOptionsUseGroupingRegistry {}
4413+
4414+
type NumberFormatOptionsUseGrouping = keyof NumberFormatOptionsUseGroupingRegistry | boolean;
4415+
44124416
interface NumberFormatOptions {
44134417
localeMatcher?: string | undefined;
44144418
style?: string | undefined;
44154419
currency?: string | undefined;
44164420
currencyDisplay?: string | undefined;
4417-
useGrouping?: boolean | undefined;
4421+
useGrouping?: NumberFormatOptionsUseGrouping | undefined;
44184422
minimumIntegerDigits?: number | undefined;
44194423
minimumFractionDigits?: number | undefined;
44204424
maximumFractionDigits?: number | undefined;
@@ -4433,7 +4437,7 @@ declare namespace Intl {
44334437
maximumFractionDigits: number;
44344438
minimumSignificantDigits?: number;
44354439
maximumSignificantDigits?: number;
4436-
useGrouping: boolean;
4440+
useGrouping: NumberFormatOptionsUseGrouping;
44374441
}
44384442

44394443
interface NumberFormat {

src/lib/libs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"es2022.regexp",
6969
"es2023.array",
7070
"es2023.collection",
71+
"es2023.intl",
7172
"esnext.decorators",
7273
"esnext.intl",
7374
"esnext.disposable",

0 commit comments

Comments
 (0)