Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: add Intl.getCanonicalLocales type definition#56079

Merged
sandersn merged 7 commits into
microsoft:mainmicrosoft/TypeScript:mainfrom
kazupon:fix/intl-get-canonicalLocaleskazupon/TypeScript:fix/intl-get-canonicalLocalesCopy head branch name to clipboard
Nov 3, 2023
Merged

fix: add Intl.getCanonicalLocales type definition#56079
sandersn merged 7 commits into
microsoft:mainmicrosoft/TypeScript:mainfrom
kazupon:fix/intl-get-canonicalLocaleskazupon/TypeScript:fix/intl-get-canonicalLocalesCopy head branch name to clipboard

Conversation

@kazupon

@kazupon kazupon commented Oct 12, 2023

Copy link
Copy Markdown
Contributor

Fixes #29129

The issue to resolve this PR is not Backlog milestone.
Intl.getCanonicalLocales type definition should be included in #45647, but unfortunately it could not do.

Even now, the Intl.getCanonicalLocales type is not resolved.
We can check it in the playground.
https://www.typescriptlang.org/play?ssl=1&ssc=6&pln=1&pc=25#code/JIOwLgNgdA5gpmAwgQxAexASwMbIgGTVwjgGcg

about Intl.getCanonicalLocales

why do i add as es2016.intl

Intl.getCanonicalLocales is supported since 2016, so some proejcts using typescript might still use es2016.
I've added es2016.intl.d.ts for compatibility and defined in it.

Parameters and return types of Intl.getCanonicalLocales

UnicodeBCP47LocaleIdentifier is not defined at es2020.intl.d.ts. In the past, A comment of #39662 has tried to support UnicodeBCP47LocaleIdentifier by defining it in es2016.
However, if we do that, it will result in a destructive change for some users, as this comment states.

UnicodeBCP47LocaleIdentifier is currently an alias for string. So, as a compromise, the parameters and return value of Intl.getCanonicalLocales are defined as string. by that way, we can keep compatibility.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 12, 2023
@typescript-bot

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #29129. If you can get it accepted, this PR will have a better chance of being reviewed.

@kazupon

kazupon commented Oct 12, 2023

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@sandersn sandersn self-assigned this Nov 3, 2023
@sandersn

sandersn commented Nov 3, 2023

Copy link
Copy Markdown
Member

It took a lot of digging, but I found proof that this was indeed added in 2016: The first page of https://402.ecma-international.org/3.0/ mentions it explicitly.

@sandersn sandersn merged commit 09fc67b into microsoft:main Nov 3, 2023
@kazupon kazupon deleted the fix/intl-get-canonicalLocales branch November 4, 2023 11:53
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

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

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.