Skip to content

Conversation

@developer-bandi
Copy link

@developer-bandi developer-bandi commented Dec 1, 2024

Add initial type for prototype

Fixes #60608

Add initial type for prototype
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 1, 2024
@developer-bandi developer-bandi marked this pull request as draft December 1, 2024 14:33
@developer-bandi
Copy link
Author

@microsoft-github-policy-service agree

@developer-bandi developer-bandi marked this pull request as ready for review December 8, 2024 08:07
@developer-bandi
Copy link
Author

@jakebailey
Copy link
Member

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 npx dprint fmt and commit the result.

*
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
*/
type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit";
Copy link
Member

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.

Copy link
Author

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.

*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration).
*/
type DurationType = Record<DurationTimeFormatUnit,number>
Copy link

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:

Suggested change
type DurationType = Record<DurationTimeFormatUnit,number>
type DurationType = Partial<Record<DurationTimeFormatUnit,number>>

*
* [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
Copy link

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.

@Wiktor102
Copy link

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.

Comment on lines 63 to 69
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">
Copy link
Contributor

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

*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat).
*/
new (locales: LocalesArgument, options: DurationFormatOptions): DurationFormat;
Copy link

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?

@developer-bandi developer-bandi force-pushed the feat/intl-DurationFormat branch from e4efa6a to 15d98aa Compare August 2, 2025 01:40
@Standard8
Copy link

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?)?

@smorimoto
Copy link

Gentle ping

@developer-bandi
Copy link
Author

Sorry for being so late, I have reflected your request for changes in PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Intl.DurationFormat missing from library definitions