Skip to content

Commit fd6f61e

Browse files
KhafraDevsandersn
andauthored
add Intl.supportedValuesOf (#53511)
Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent a26175b commit fd6f61e

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

src/lib/es2022.intl.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,13 @@ declare namespace Intl {
8888
*/
8989
supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
9090
};
91+
92+
/**
93+
* Returns a sorted array of the supported collation, calendar, currency, numbering system, timezones, and units by the implementation.
94+
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
95+
*
96+
* @param key A string indicating the category of values to return.
97+
* @returns A sorted array of the supported values.
98+
*/
99+
function supportedValuesOf(key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"): string[];
91100
}

tests/baselines/reference/es2022IntlAPIs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ for (const zoneName of timezoneNames) {
77
timeZoneName: zoneName,
88
});
99
}
10+
11+
const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const;
12+
for (const key of enumerationKeys) {
13+
var supported = Intl.supportedValuesOf(key);
14+
}
1015

1116

1217
//// [es2022IntlAPIs.js]
@@ -18,3 +23,7 @@ for (const zoneName of timezoneNames) {
1823
timeZoneName: zoneName,
1924
});
2025
}
26+
const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'];
27+
for (const key of enumerationKeys) {
28+
var supported = Intl.supportedValuesOf(key);
29+
}

tests/baselines/reference/es2022IntlAPIs.symbols

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ for (const zoneName of timezoneNames) {
2424
});
2525
}
2626

27+
const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const;
28+
>enumerationKeys : Symbol(enumerationKeys, Decl(es2022IntlAPIs.ts, 9, 5))
29+
>const : Symbol(const)
30+
31+
for (const key of enumerationKeys) {
32+
>key : Symbol(key, Decl(es2022IntlAPIs.ts, 10, 10))
33+
>enumerationKeys : Symbol(enumerationKeys, Decl(es2022IntlAPIs.ts, 9, 5))
34+
35+
var supported = Intl.supportedValuesOf(key);
36+
>supported : Symbol(supported, Decl(es2022IntlAPIs.ts, 11, 5))
37+
>Intl.supportedValuesOf : Symbol(Intl.supportedValuesOf, Decl(lib.es2022.intl.d.ts, --, --))
38+
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2019.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --) ... and 3 more)
39+
>supportedValuesOf : Symbol(Intl.supportedValuesOf, Decl(lib.es2022.intl.d.ts, --, --))
40+
>key : Symbol(key, Decl(es2022IntlAPIs.ts, 10, 10))
41+
}
42+

tests/baselines/reference/es2022IntlAPIs.types

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,27 @@ for (const zoneName of timezoneNames) {
3535
});
3636
}
3737

38+
const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const;
39+
>enumerationKeys : readonly ["calendar", "collation", "currency", "numberingSystem", "timeZone", "unit"]
40+
>['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const : readonly ["calendar", "collation", "currency", "numberingSystem", "timeZone", "unit"]
41+
>['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] : readonly ["calendar", "collation", "currency", "numberingSystem", "timeZone", "unit"]
42+
>'calendar' : "calendar"
43+
>'collation' : "collation"
44+
>'currency' : "currency"
45+
>'numberingSystem' : "numberingSystem"
46+
>'timeZone' : "timeZone"
47+
>'unit' : "unit"
48+
49+
for (const key of enumerationKeys) {
50+
>key : "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"
51+
>enumerationKeys : readonly ["calendar", "collation", "currency", "numberingSystem", "timeZone", "unit"]
52+
53+
var supported = Intl.supportedValuesOf(key);
54+
>supported : string[]
55+
>Intl.supportedValuesOf(key) : string[]
56+
>Intl.supportedValuesOf : (key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit") => string[]
57+
>Intl : typeof Intl
58+
>supportedValuesOf : (key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit") => string[]
59+
>key : "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"
60+
}
61+

tests/cases/conformance/es2022/es2022IntlAPIs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ for (const zoneName of timezoneNames) {
88
timeZoneName: zoneName,
99
});
1010
}
11+
12+
const enumerationKeys = ['calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'] as const;
13+
for (const key of enumerationKeys) {
14+
var supported = Intl.supportedValuesOf(key);
15+
}

0 commit comments

Comments
 (0)