-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Add the type of Intl.DurationFormat to the lib. #60646
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
base: main
Are you sure you want to change the base?
Add the type of Intl.DurationFormat to the lib. #60646
Conversation
|
@microsoft-github-policy-service agree |
|
I referred to the two links below, but lint does not work properly. Can I get help? -https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#get-started |
|
Your CI is passing linting, so I'm not sure what you mean. The section you are looking for to fix tests is https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#managing-the-baselines For formatting, run |
| * | ||
| * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). | ||
| */ | ||
| type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit"; |
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.
This type must not be renamed, as that would be a breaking change.
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.
All existing type modifications were returned, and only cases where the existing type name was not applied were left. If there are any issues with this item, I will reinstate it.
src/lib/esnext.intl.d.ts
Outdated
| * | ||
| * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration). | ||
| */ | ||
| type DurationType = Record<DurationTimeFormatUnit,number> |
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.
tried this locally but with strict type settings this causes all fields to be required. I believe it is valid for the type to be partial, like {hours: 1, minutes: 30} so this seems like it should be:
| type DurationType = Record<DurationTimeFormatUnit,number> | |
| type DurationType = Partial<Record<DurationTimeFormatUnit,number>> | |
src/lib/esnext.intl.d.ts
Outdated
| * | ||
| * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#fractionaldigits). | ||
| */ | ||
| type fractionalDigitsOption = 0|1|2|3|4|5|6|7|8|9 |
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.
Out of curiosity, is it intentional that this type starts with lowercase? It looks a bit out of place as all the others are in PascalCase.
|
Is this PR being worked on? It seems to be pretty important, given that for almost 4 months now, this API has had the "Baseline Newly available" status. |
src/lib/esnext.intl.d.ts
Outdated
| years?: Omit<DurationFormatOptions,"numeric"|"2-digit"> | ||
| yearsDisplay?:DurationFormatDisplayOption | ||
| months?: Omit<DurationFormatOptions,"numeric"|"2-digit"> | ||
| monthsDisplay?: DurationFormatDisplayOption | ||
| weeks?: Omit<DurationFormatOptions,"numeric"|"2-digit"> | ||
| weeksDisplay?: DurationFormatDisplayOption | ||
| days?: Omit<DurationFormatOptions,"numeric"|"2-digit"> |
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.
Maybe we shouldn't use Omit.
FYI: #54451
src/lib/esnext.intl.d.ts
Outdated
| * | ||
| * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat). | ||
| */ | ||
| new (locales: LocalesArgument, options: DurationFormatOptions): DurationFormat; |
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 both of these parameters be optional?
e4efa6a to
15d98aa
Compare
|
It looks like there's just one change remaining to complete this. Would it be possible that it could happen soon, or should someone take over (or maybe a maintainer can change the branch?)? |
|
Gentle ping |
|
Sorry for being so late, I have reflected your request for changes in PR. |
Add initial type for prototype
Fixes #60608