-
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
Intl.DisplayNames
options object type needs to be split
#48218
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Help Wanted
You can do this
Milestone
Comments
tchetwin
changed the title
Mar 11, 2022
Intl.DisplayName
options object type needs to be splitIntl.DisplayNames
options object type needs to be split
RyanCavanaugh
added
Bug
A bug in TypeScript
Help Wanted
You can do this
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
labels
Mar 11, 2022
CC: @gfyoung |
gfyoung
added a commit
to forking-repos/TypeScript
that referenced
this issue
Mar 14, 2022
Thanks @tchetwin for filing this: just opened a PR to update these. |
gfyoung
added a commit
to forking-repos/TypeScript
that referenced
this issue
Mar 20, 2022
gfyoung
added a commit
to forking-repos/TypeScript
that referenced
this issue
Mar 20, 2022
gfyoung
added a commit
to forking-repos/TypeScript
that referenced
this issue
Mar 21, 2022
gabritto
pushed a commit
that referenced
this issue
Mar 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Help Wanted
You can do this
Bug Report
🔎 Search Terms
DisplayNames, Intl, locale
🕗 Version & Regression Information
The behaviour was altered in TypeScript 4.6.2, but it was differently incorrect prior to that:
locale
#46845, resulted in fix(46845): Add missing "locale" field to Intl.DisplayNamesOptions #46849, merged 3rd Jan -> 4.6⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Type errors in the above code for valid patterns, no type errors for invalid patterns.
🙂 Expected behavior
Only valid type errors, accurate representation of the API
Notes
The
DisplayNamesOptions
interface
:TypeScript/src/lib/es2020.intl.d.ts
Lines 294 to 300 in a4f5555
...is currently shared by
Intl.DisplayNames()
constructor, andIntl.DisplayNames.prototype.resolvedOptions()
. While the underlying objects share several properties, they are not a perfect match as the types suggest.Per MDN:
Intl.DisplayNames()
constructor should accept an object with (Partial<>
):localeMatcher
style
type
languageDisplay
fallback
Intl.DisplayNames.prototype.resolvedOptions()
should return an object with:locale
style
type
fallback
ECMA-402 links:
Intl.DisplayNames()
constructorIntl.DisplayNames.prototype.resolvedOptions()
Shoutout to @mkubilayk who spotted this during our TypeScript update!
Suggested Fix
These types are not compatible, suggesting they should be split into something like (bikeshed)
DisplayNamesOptions
andDisplayNamesResolvedOptions
.Probably a Good First Issue™
The text was updated successfully, but these errors were encountered: