fix: add Intl.getCanonicalLocales type definition#56079
Merged
sandersn merged 7 commits intomicrosoft:mainfrom Nov 3, 2023
Merged
fix: add Intl.getCanonicalLocales type definition#56079sandersn merged 7 commits intomicrosoft:mainfrom
Intl.getCanonicalLocales type definition#56079sandersn merged 7 commits intomicrosoft:mainfrom
Conversation
Collaborator
|
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. |
Contributor
Author
|
@microsoft-github-policy-service agree |
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
approved these changes
Nov 3, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #29129
The issue to resolve this PR is not
Backlogmilestone.Intl.getCanonicalLocalestype definition should be included in #45647, but unfortunately it could not do.Even now, the
Intl.getCanonicalLocalestype 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.getCanonicalLocaleswhy do i add as
es2016.intlIntl.getCanonicalLocalesis supported since 2016, so some proejcts using typescript might still use es2016.I've added
es2016.intl.d.tsfor compatibility and defined in it.Parameters and return types of
Intl.getCanonicalLocalesUnicodeBCP47LocaleIdentifieris not defined ates2020.intl.d.ts. In the past, A comment of #39662 has tried to supportUnicodeBCP47LocaleIdentifierby defining it in es2016.However, if we do that, it will result in a destructive change for some users, as this comment states.
UnicodeBCP47LocaleIdentifieris currently an alias forstring. So, as a compromise, the parameters and return value ofIntl.getCanonicalLocalesare defined as string. by that way, we can keep compatibility.