You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Intl.Locale to the es2020 build target libs. It is supported in recent NodeJS versions, and recent Chrome versions, making it a suitable feature for inclusion.
About the types... I think it's a bit too restrictive and not future proof to require only the enumerated values in the option, especially since the standard isn't fixed... Maybe add "| string" as a possible option, so that IDEs can assist, but also have TS not complain if a different value is supplied? Keep (and maybe even export) the enumerations, so that if one wants to force the value to be among the enumerated, they can?
The main reason for string type instead of enum is bc ECMA402 does not require CLDR so those are considered implementation details. You can have a runtime env that does not support those things.
Ryan Cavanaugh (@RyanCavanaugh) shouldn't the criteria be stage 4? Stage 4 does include adoption criteria of at least 2 tst262-compatible implementations
Long Ho (@longlho) thanks for your comments.
I brought it up as draft PR against this repo and removed the enum for numberingSystem as well.
Let's see when we get green lights from the maintainers for this.
It appears Intl.Locale will be available with Safari 14:
Hi, I need the types for a project. I have copied it from the PR to a .d.ts file but that only works while development within jest. I can't build it with my tooling (microbundle -> rollup -> rollup-plugin-typescript2) because the types are missing then. I did not found any Types (@types) or other solution to get it working. I wonder that this types is not supported by typescript at esnext/es2020 yet. Has anyone a idea how to add the types until this is supported by TS?
Could not get it (@formatjs/intl-locale) to work as a source of the types for Intl.Locale. The package exports a class Locale but does not extend the Intl namespace with Locale. It seems all of their polyfills need the es typescript types right and that's not possible for Intl.Locale (and what this issues is about).
So I don't get the point why this (Stage 4 since February) is still not included in the es2020/esnext types. In my opinion the types should be published before the polyfills. Getting types from a polyfill and "hack" them into a project feels the wrong way (same for copy and paste types from PR). Don't see any reason why a Stage 4 Feature should wait for the browsers. Then we could still wait for some features because of Apples "let's do it our incompatible way" Safari or the Mozilla "the specs only say it has to provide this properties, not that the values make sense" Firefox. ^^
Long Ho (@longlho) that brought me on the right way. But not declaring in a d.ts file. That would still break the build. But inside of my main entry point which only exports the main components:
What do I have to add to my tsconfig.json file in order to use Intl.Locale? I'm still getting errors when I try to access it. I'm using the latest typescript: v4.4.3
Activity
RyanCavanaugh commentedon Mar 17, 2020
We'd prefer things be more broadly adopted (e.g. in Safari) before adding them to the built-in definitions.
Dangoo commentedon Jun 9, 2020
Thanks Vasil Rangelov (@boenrobot) for bringing this up!
This was added in Safari TP 107 (261215) as listed here on May 28th:
https://webkit.org/blog/10585/release-notes-for-safari-technology-preview-107/
Dangoo commentedon Jun 9, 2020
Already have the types prepared. So just let me know when you are ready to accept a PR for that.
boenrobot commentedon Jun 12, 2020
Cool!
About the types... I think it's a bit too restrictive and not future proof to require only the enumerated values in the option, especially since the standard isn't fixed... Maybe add "| string" as a possible option, so that IDEs can assist, but also have TS not complain if a different value is supplied? Keep (and maybe even export) the enumerations, so that if one wants to force the value to be among the enumerated, they can?
Dangoo commentedon Jun 15, 2020
Vasil Rangelov (@boenrobot) good catch!
I think this would do?
Regarding the export this should already be the case since declared as namespace. So e.g.
Intl.LDMLCalendarKeyshould already be available.longlho commentedon Jul 19, 2020
Couple of comments here:
LMDLCalendarKeyshould just be astring. See https://ecma-international.org/ecma-402/7.0/index.html 10.1.3 Intl.Locale. There's no verification forcalendar.LMDLCaseFirstshould not be| string. Invalid value will triggerRangeError, see https://ecma-international.org/ecma-402/7.0/index.html#sec-Intl.LocaleLDMLCollationKeyshould just bestring.LDMLHourCycleKeyshould not be| string. Any value that's noth11,h12,h23,h24will throw aRangeError. See https://ecma-international.org/ecma-402/7.0/index.html#sec-InitializeDateTimeFormatLDMLNumberingSystemKeyshould not be| string. See https://ecma-international.org/ecma-402/7.0/index.html table 4. Future addition to this will require a Normative spec change. See Normative: Update Table 4 Numbering systems tc39/ecma402#438 for example.ScriptCodeshould just bestring.The main reason for
stringtype instead ofenumis bc ECMA402 does not require CLDR so those are considered implementation details. You can have a runtime env that does not support those things.longlho commentedon Jul 19, 2020
Ryan Cavanaugh (@RyanCavanaugh) shouldn't the criteria be stage 4? Stage 4 does include adoption criteria of at least 2 tst262-compatible implementations
Dangoo commentedon Jul 19, 2020
Long Ho (@longlho) thanks for your comments.
I brought it up as draft PR against this repo and removed the enum for
numberingSystemas well.Let's see when we get green lights from the maintainers for this.
It appears

Intl.Localewill be available with Safari 14:orta commentedon Jul 21, 2020
Yeah, this should be OK to go now, tested it in Firefox too. 👍
hbroer commentedon Aug 18, 2020
Hi, I need the types for a project. I have copied it from the PR to a .d.ts file but that only works while development within jest. I can't build it with my tooling (microbundle -> rollup -> rollup-plugin-typescript2) because the types are missing then. I did not found any Types (@types) or other solution to get it working. I wonder that this types is not supported by typescript at esnext/es2020 yet. Has anyone a idea how to add the types until this is supported by TS?
longlho commentedon Aug 18, 2020
You can use @formatjs/intl-locale
hbroer commentedon Aug 19, 2020
Thanks Long Ho (@longlho) will try that out.
hbroer commentedon Aug 19, 2020
Could not get it (@formatjs/intl-locale) to work as a source of the types for
Intl.Locale. The package exports aclass Localebut does not extend theIntlnamespace withLocale. It seems all of their polyfills need the es typescript types right and that's not possible for Intl.Locale (and what this issues is about).So I don't get the point why this (Stage 4 since February) is still not included in the es2020/esnext types. In my opinion the types should be published before the polyfills. Getting types from a polyfill and "hack" them into a project feels the wrong way (same for copy and paste types from PR). Don't see any reason why a Stage 4 Feature should wait for the browsers. Then we could still wait for some features because of Apples "let's do it our incompatible way" Safari or the Mozilla "the specs only say it has to provide this properties, not that the values make sense" Firefox. ^^
longlho commentedon Aug 19, 2020
u can just add a
to a
d.tsfile or the like.Unfortunately the rate of merging PR seems quite slow.
hbroer commentedon Aug 19, 2020
Long Ho (@longlho) that brought me on the right way. But not declaring in a d.ts file. That would still break the build. But inside of my main entry point which only exports the main components:
Thanks for that. 👍 Now I can keep working on that library. ❤️
orta commentedon Sep 8, 2021
This is in with #45647 👍🏻
smac89 commentedon Sep 13, 2021
What do I have to add to my tsconfig.json file in order to use
Intl.Locale? I'm still getting errors when I try to access it. I'm using the latest typescript: v4.4.3orta commentedon Sep 14, 2021
You'd need to use a nightly build to get access to features in main which are planned for 4.5