GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: add `Intl.getCanonicalLocales` type definition by kazupon · Pull Request #56079 · microsoft/TypeScript

Conversation

@kazupon

@kazupon kazuya kawaguchi (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

  • MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales
  • ecma402 spec: https://tc39.es/ecma402/#sec-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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kazuya kawaguchi (kazupon) added 2 commits October 12, 2023 18:00
@kazupon
fix: add Intl.getCanonicalLocales type definition
39ad254
@kazupon
fix: update jsdoc
5394a49
@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 12, 2023
@typescript-bot

TypeScript Bot (typescript-bot) commented Oct 12, 2023

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kazupon

kazuya kawaguchi (kazupon) commented Oct 12, 2023

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kazuya kawaguchi (kazupon) added 4 commits October 12, 2023 18:50
@kazupon
fix: line ending
6ddf1da
@kazupon
fix: more line ending
f1dc6a1
@kazupon
fix
57ae4a5
@kazupon
fix: line ending
26cc921
@sandersn Nathan Shively-Sanders (sandersn) self-assigned this Nov 3, 2023
@sandersn
Nathan Shively-Sanders (sandersn) requested review from navya9singh and Nathan Shively-Sanders (sandersn) November 3, 2023 15:33
@sandersn

Nathan Shively-Sanders (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.

kazupon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sandersn
Nathan Shively-Sanders (sandersn) approved these changes Nov 3, 2023
View reviewed changes
@sandersn
Merge branch 'main' into fix/intl-get-canonicalLocales
b2bd548
@sandersn
Nathan Shively-Sanders (sandersn) merged commit 09fc67b into microsoft:main Nov 3, 2023
@kazupon
kazuya kawaguchi (kazupon) deleted the fix/intl-get-canonicalLocales branch November 4, 2023 11:53
@haoqunjiang Haoqun Jiang (haoqunjiang) mentioned this pull request Feb 29, 2024
feat: use Intl.getCanonicalLocales check locale vuejs/create-vue#450
Merged
@microsoft 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.

Reviewers

@sandersn Nathan Shively-Sanders (sandersn) sandersn approved these changes
@navya9singh navya9singh Awaiting requested review from navya9singh

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@sandersn Nathan Shively-Sanders (sandersn)

Labels

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

Projects

PR Backlog
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kazupon @typescript-bot @sandersn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.