TypeScript: [i18n] Intl getCanonicalLocales / RelativeTimeFormat / ListFormat > 2339 error
TypeScript Version: 3.2.2
Search Terms: Intl.getCanonicalLocales TS TypeScript Error 2339 undefined i18n
Code
Intl.getCanonicalLocales('EN-US');
Expected behavior: Code works, and returns [“en-US”] https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Intl/getCanonicalLocales
Actual behavior: TS Error 2339, the property getCanonicalLocales does not exists on Intl
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 17 (4 by maintainers)
Commits related to this issue
- feat(lib/es2020.intl): Add `Intl.RelativeTimeFormat` (part of #29129); — committed to DmitryMakhnev/TypeScript by deleted user 4 years ago
- fix(lib/es2020.intl): fix for tests and linters `Intl.RelativeTimeFormat` (part of #29129); — committed to DmitryMakhnev/TypeScript by deleted user 4 years ago
- Add d.ts for Intl.RelativeTimeFormat (#36084) * feat(lib/es2020.intl): Add `Intl.RelativeTimeFormat` (part of #29129); * fix(lib/es2020.intl): fix for tests and linters `Intl.RelativeTimeFormat` (... — committed to microsoft/TypeScript by DmitryMakhnev 4 years ago
Everything appears to be updated and available in one of the compiler lib.d.ts versions such as ES2020.Intl… except for
getCanonicalLocales. That seems strange to me.It is now stage 4.
Same thing with
Code
Expected behavior: Code works https://developers.google.com/web/updates/2018/12/intl-listformat
Actual behavior: TS Error 2339, the property ListFormat does not exists on Intl
Drafts are not included into libs. You can declare a
d.tsfile with the definitions:Must have been after the 5.3 cutoff, because it’s only in
mainbranch, notrelease-5.3. That means it’ll be available in 5.4.Try adding esnext & upgrade to 4.7
One of the polyfills for
Intl.ListFormathas its own declaration file that you can use in the meantime.RelativeTimeFormathas already been added.#39662 is pending for
getCanonicalLocales