-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Various Intl-related constructors and methods reject Intl.Locale objects in locales parameter #52946
Comments
A workaround
|
@singhBinary what's this a workaround for? This doesn't seem to be related to this issue, which concerns allowing |
If someone have facing that same problem as me with const options: Intl.DateTimeFormatOptions = {
weekday: "long",
year: "numeric",
month: "short",
day: "numeric",
} |
@marcosbrasil I'm not sure what problem you're referring to, this is your first comment on this issue. Did you mean to comment on a different issue? This also doesn't seem related to |
@lionel-rowe , sorry if that was inappropriate, feel free to remove my comment if that is the case. But this issue was the most "foundable" so I thought that someone with the same issue, would end up coming here. The issue is related with const options = {
weekday: "long",
year: "numeric",
month: "short",
day: "numeric",
}
date.toLocaleDateString('pt-br', options) This generates the following error:
|
@marcosbrasil No worries! I can't remove/hide comments as I'm not a maintainer of this repository (perhaps a maintainer can help tidy up this thread if they come across it), but in future, I recommend Reddit or Stack Overflow for this kind of question rather than posting in or opening an issue. GitHub issues are usually for reporting bugs or feature requests to do with the library itself, rather than debugging your own userland code. I wrote up an explanation of your issue and how to fix it in this TypeScript playground. |
lib Update Request
Various
Intl
-related constructors and methods rejectIntl.Locale
objects in theirlocales
parameter.Related to #47802 (Signature for
toLocale[X]String
is missingIntl.Locale
), but the updated signature is still missing for various otherIntl
-related constructors and methods.Draft fix here:
main...lionel-rowe:TypeScript:fix/locales-argument
I can submit as a PR once this issue is accepted, or happy for someone else to pick it up otherwise.
Configuration Check
My compilation target is
ES2022
and my lib isthe default
.Missing/Incorrect Definition
Various, including but not limited to:
String#toLocaleUpperCase
Intl.Collator
constructorIntl.DateTimeFormat
constructorIntl.ListFormat
constructorIntl.Segmenter
constructorSample Code
Documentation Link
https://tc39.es/ecma402/#sec-canonicalizelocalelist
CanonicalizeLocaleList
is called on all suchlocales
arguments, iterating through them as an array, checking for the[[InitializedLocale]]
internal slot (used to identifyIntl.Locale
objects), and reading the[[Locale]]
internal slot if it exists (forIntl.Locale
objects, this is the string representation of the locale). Thus'x'.toLocaleUpperCase('es')
behaves identically to'x'.toLocaleUpperCase(new Locale('es'))
🔎 Search Terms
Intl.Locale
LocalesArgument
CanonicalizeLocaleList
The text was updated successfully, but these errors were encountered: