Skip to content

Commit

Permalink
Adds more Intl.ResolvedDateTimeFormatOptions, and hooks up Intl for E…
Browse files Browse the repository at this point in the history
…S2021 (#45905)

* Adds more ResolvedDateTimeFormatOptions to the Intl APIs

* Fix tests
  • Loading branch information
Orta Therox committed Sep 23, 2021
1 parent a4f9bf0 commit 61d2939
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/es2021.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/// <reference lib="es2021.promise" />
/// <reference lib="es2021.string" />
/// <reference lib="es2021.weakref" />
/// <reference lib="es2021.intl" />
9 changes: 9 additions & 0 deletions src/lib/es2021.intl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ declare namespace Intl {
fractionalSecondDigits?: 0 | 1 | 2 | 3 | undefined;
}

interface ResolvedDateTimeFormatOptions {
formatMatcher?: "basic" | "best fit" | "best fit";
dateStyle?: "full" | "long" | "medium" | "short";
timeStyle?: "full" | "long" | "medium" | "short";
hourCycle?: "h11" | "h12" | "h23" | "h24";
dayPeriod?: "narrow" | "short" | "long";
fractionalSecondDigits?: 0 | 1 | 2 | 3;
}

interface NumberFormat {
formatRange(startDate: number | bigint, endDate: number | bigint): string;
formatRangeToParts(startDate: number | bigint, endDate: number | bigint): NumberFormatPart[];
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/formatToPartsBigInt.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
// Test Intl methods with new parameter type
new Intl.NumberFormat("fr").formatToParts(3000n);
>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 1 more)
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more)
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --))

new Intl.NumberFormat("fr").formatToParts(BigInt(123));
>new Intl.NumberFormat("fr").formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 1 more)
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
>Intl.NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
>Intl : Symbol(Intl, Decl(lib.es5.d.ts, --, --), Decl(lib.es2017.intl.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.intl.d.ts, --, --) ... and 2 more)
>NumberFormat : Symbol(Intl.NumberFormat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2018.intl.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2021.intl.d.ts, --, --))
>formatToParts : Symbol(Intl.NumberFormat.formatToParts, Decl(lib.es2018.intl.d.ts, --, --))
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))

0 comments on commit 61d2939

Please sign in to comment.