Skip to content

Commit a056783

Browse files
printfnptomato
authored andcommitted
Polyfill: Fix type definition of Duration.toLocaleString
1 parent 50489ad commit a056783

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

polyfill/index.d.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,36 @@ export namespace Temporal {
519519
nanoseconds?: number | undefined;
520520
};
521521

522+
/**
523+
* Options for Intl.DurationFormat
524+
*/
525+
export type DurationFormatOptions = {
526+
localeMatcher?: 'lookup' | 'best fit' | undefined;
527+
numberingSystem?: string | undefined;
528+
style?: 'long' | 'short' | 'narrow' | 'digital' | undefined;
529+
years?: 'long' | 'short' | 'narrow' | undefined;
530+
yearsDisplay?: 'always' | 'auto' | undefined;
531+
months?: 'long' | 'short' | 'narrow' | undefined;
532+
monthsDisplay?: 'always' | 'auto' | undefined;
533+
weeks?: 'long' | 'short' | 'narrow' | undefined;
534+
weeksDisplay?: 'always' | 'auto' | undefined;
535+
days?: 'long' | 'short' | 'narrow' | undefined;
536+
daysDisplay?: 'always' | 'auto' | undefined;
537+
hours?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined;
538+
hoursDisplay?: 'always' | 'auto' | undefined;
539+
minutes?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined;
540+
minutesDisplay?: 'always' | 'auto' | undefined;
541+
seconds?: 'long' | 'short' | 'narrow' | 'numeric' | '2-digit' | undefined;
542+
secondsDisplay?: 'always' | 'auto' | undefined;
543+
milliseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined;
544+
millisecondsDisplay?: 'always' | 'auto' | undefined;
545+
microseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined;
546+
microsecondsDisplay?: 'always' | 'auto' | undefined;
547+
nanoseconds?: 'long' | 'short' | 'narrow' | 'numeric' | undefined;
548+
nanosecondsDisplay?: 'always' | 'auto' | undefined;
549+
fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
550+
};
551+
522552
/**
523553
*
524554
* A `Temporal.Duration` represents an immutable duration of time which can be
@@ -564,7 +594,7 @@ export namespace Temporal {
564594
subtract(other: Temporal.Duration | DurationLike | string): Temporal.Duration;
565595
round(roundTo: DurationRoundTo): Temporal.Duration;
566596
total(totalOf: DurationTotalOf): number;
567-
toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
597+
toLocaleString(locales?: globalThis.Intl.LocalesArgument, options?: DurationFormatOptions): string;
568598
toJSON(): string;
569599
toString(options?: ToStringPrecisionOptions): string;
570600
valueOf(): never;

0 commit comments

Comments
 (0)