Skip to content

[i18n] Intl getCanonicalLocales / RelativeTimeFormat / ListFormat > 2339 error #29129

Closed

Description

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

Activity

  1. dtruffaut commented on Dec 23, 2018

    @dtruffaut
    Author

    Same thing with

    Code

    new Intl.RelativeTimeFormat('en');
    

    Expected behavior:
    Code works
    https://developers.google.com/web/updates/2018/10/intl-relativetimeformat

    Actual behavior:
    TS Error 2339, the property RelativeTimeFormat does not exists on Intl

  2. dtruffaut commented on Dec 23, 2018

    @dtruffaut
    Author

    Same thing with

    Code

    new Intl.ListFormat('en');
    

    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

  3. changed the title [-][i18n] Intl.getCanonicalLocales > 2339 error[/-] [+][i18n] Intl getCanonicalLocales / RelativeTimeFormat / ListFormat > 2339 error[/+] on Dec 23, 2018
  4. dtruffaut commented on Dec 23, 2018

    @dtruffaut
    Author

    How can I extend the Intl object in a types.d.ts file ?

  5. j-oliveras commented on Dec 23, 2018

    @j-oliveras
    Contributor

    Drafts are not included into libs. You can declare a d.ts file with the definitions:

    declare namespace Intl {
        function getCanonicalLocales(locales: string | string[]): string[];
    
        class RelativeTimeFormat {
            constructor(locale: string);
    
            // TODO Add other properties/methods
        }
        // const RelativeTimeFormat: any; // Use this instead of the class if you don't want to declare all properties/methods
    
        class ListFormat {
            constructor(locale: string);
    
            // TODO Add other properties/methods
        }
        // const ListFormat: any; // Use this instead of the class if you don't want to declare all properties/methods
    }
  6. dtruffaut commented on Dec 23, 2018

    @dtruffaut
    Author

    Thank you !

    Administrators will close this issue when the features are definitively implemented.
    For now, the workaround works like a charm.

  7. Dassderdie commented on Oct 25, 2019

    @Dassderdie

    Is there any update on this? RelativeDateTime should is now more than a draft: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat

  8. longlho commented on Oct 25, 2019

    @longlho
    Contributor
  9. jessamp commented on Aug 13, 2020

    @jessamp

    Has Intl.ListFormat been added for support?

  10. alex-kinokon commented on Sep 17, 2020

    @alex-kinokon

    It is now stage 4.

  11. noinkling commented on Nov 17, 2020

    @noinkling

    One of the polyfills for Intl.ListFormat has its own declaration file that you can use in the meantime.

    RelativeTimeFormat has already been added.

    #39662 is pending for getCanonicalLocales

  12. blessanm86 commented on Aug 20, 2022

    @blessanm86

    I tried adding the target as ES2021 mentioned in the linked issue but still get an error for ListFormat.
    I am using typescript version v4.6.2

  13. longlho commented on Aug 20, 2022

    @longlho
    Contributor

    Try adding esnext & upgrade to 4.7

  14. wycats commented on Jan 30, 2023

    @wycats

    What's the deal with this?

  15. cvkline commented on Feb 2, 2023

    @cvkline

    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.

  16. AkaraChen commented on Apr 26, 2023

    @AkaraChen

    Any update on it?

  17. pindatm commented on Nov 23, 2023

    @pindatm

    I see this is merged, what version can we expect this in? It doesn't seem to be in 5.3.2 using this config

  18. sandersn commented on Nov 27, 2023

    @sandersn
    Member

    Must have been after the 5.3 cutoff, because it's only in main branch, not release-5.3.
    That means it'll be available in 5.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions