-
Notifications
You must be signed in to change notification settings - Fork 12.8k
fix(56513): Allow Intl locales to be readonly arrays #56621
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
Conversation
Updates the definitions for Intl.getCanonicalLocales() and Intl.PluralRules constructors/methods to accept readonly arrays.
@microsoft-github-policy-service agree |
src/lib/es2016.intl.d.ts
Outdated
@@ -9,5 +9,5 @@ declare namespace Intl { | |||
* @param locale A list of String values for which to get the canonical locale names | |||
* @returns An array containing the canonical and validated locale names. | |||
*/ | |||
function getCanonicalLocales(locale?: string | string[]): string[]; | |||
function getCanonicalLocales(locale?: string | string[] | Readonly<string[]>): string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
function getCanonicalLocales(locale?: string | string[] | Readonly<string[]>): string[]; | |
function getCanonicalLocales(locale?: string | readonly string[]): string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also updated. Thank you
Fixes #56513:
Updates the definitions for
Intl.getCanonicalLocales()
andIntl.PluralRules
constructors/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
.