fix(56513): Allow Intl locales to be readonly arrays#56621
Merged
sandersn merged 4 commits intomicrosoft:mainfrom Dec 13, 2023
Merged
fix(56513): Allow Intl locales to be readonly arrays#56621sandersn merged 4 commits intomicrosoft:mainfrom
sandersn merged 4 commits intomicrosoft:mainfrom
Conversation
Updates the definitions for Intl.getCanonicalLocales() and Intl.PluralRules constructors/methods to accept readonly arrays.
Contributor
Author
|
@microsoft-github-policy-service agree |
sandersn
requested changes
Dec 12, 2023
src/lib/es2016.intl.d.ts
Outdated
| * @returns An array containing the canonical and validated locale names. | ||
| */ | ||
| function getCanonicalLocales(locale?: string | string[]): string[]; | ||
| function getCanonicalLocales(locale?: string | string[] | Readonly<string[]>): string[]; |
Member
There was a problem hiding this comment.
shouldn't this be readonly string[] or ReadonlyArray<string>? (notably, the baselines print the type as string | string[] | readonly string[])
Also, the previous PR added readonly on the existing arrays. I think that's good enough here too:
Suggested change
| function getCanonicalLocales(locale?: string | string[] | Readonly<string[]>): string[]; | |
| function getCanonicalLocales(locale?: string | readonly string[]): string[]; |
Contributor
Author
There was a problem hiding this comment.
Ah, that makes sense. I was worried about excluding non-readonly arrays but see that it doesn't behave that way (TIL). Updated.
src/lib/es2018.intl.d.ts
Outdated
| new (locales?: string | string[], options?: PluralRulesOptions): PluralRules; | ||
| (locales?: string | string[], options?: PluralRulesOptions): PluralRules; | ||
| supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit"; }): string[]; | ||
| new (locales?: string | string[] | Readonly<string[]>, options?: PluralRulesOptions): PluralRules; |
Contributor
Author
There was a problem hiding this comment.
Also updated. Thank you
sandersn
approved these changes
Dec 13, 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 #56513:
Updates the definitions for
Intl.getCanonicalLocales()andIntl.PluralRulesconstructors/methods to accept readonly arrays. Several of the locations mentioned in the issue seem to be correctly defined now (essentially >= es2020) since they build offLocalesArgument.