Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dtruffaut opened this issue Dec 22, 2018 · 17 comments · Fixed by #56079
Closed

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

dtruffaut opened this issue Dec 22, 2018 · 17 comments · Fixed by #56079
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@dtruffaut
Copy link

dtruffaut commented Dec 22, 2018

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

@dtruffaut
Copy link
Author

dtruffaut commented Dec 23, 2018

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

@dtruffaut
Copy link
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

@dtruffaut dtruffaut changed the title [i18n] Intl.getCanonicalLocales > 2339 error [i18n] Intl getCanonicalLocales / RelativeTimeFormat / ListFormat > 2339 error Dec 23, 2018
@dtruffaut
Copy link
Author

dtruffaut commented Dec 23, 2018

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

@j-oliveras
Copy link
Contributor

j-oliveras commented Dec 23, 2018

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
}

@dtruffaut
Copy link
Author

dtruffaut commented Dec 23, 2018

Thank you !

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

@weswigham weswigham added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Dec 25, 2018
@Dassderdie
Copy link

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

@longlho
Copy link
Contributor

longlho commented Oct 25, 2019 via email

DmitryMakhnev pushed a commit to DmitryMakhnev/TypeScript that referenced this issue Jan 8, 2020
DmitryMakhnev pushed a commit to DmitryMakhnev/TypeScript that referenced this issue Jan 8, 2020
orta pushed a commit that referenced this issue May 20, 2020
* feat(lib/es2020.intl): Add `Intl.RelativeTimeFormat` (part of #29129);

* fix(lib/es2020.intl): fix for tests and linters `Intl.RelativeTimeFormat` (part of #29129);

* feat(lib/es2020.intl): Add TSDoc for `Intl.RelativeTimeFormat` by review request #36084 (comment);

* fix(lib/es2020.intl): Fix for tests;

Co-authored-by: Dmitry Makhnev <[email protected]>
@jessamp
Copy link

jessamp commented Aug 13, 2020

Has Intl.ListFormat been added for support?

@alex-kinokon
Copy link

It is now stage 4.

@noinkling
Copy link

noinkling commented Nov 17, 2020

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

@blessanm86
Copy link

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

@longlho
Copy link
Contributor

longlho commented Aug 20, 2022

Try adding esnext & upgrade to 4.7

@wycats
Copy link

wycats commented Jan 30, 2023

What's the deal with this?

@cvkline
Copy link

cvkline commented Feb 2, 2023

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.

@AkaraChen
Copy link

Any update on it?

@PindaPixel
Copy link

PindaPixel commented Nov 23, 2023

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

@sandersn
Copy link
Member

sandersn commented Nov 27, 2023

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
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.