From 55014fb9cbf68e14e556cbb8b3952685bc0491ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sundstr=C3=B6m?= Date: Tue, 12 May 2020 20:17:08 -0700 Subject: [PATCH 1/2] fix: fixes #35865 - document and flesh out legal Intl.DateTimeFormatOptions types --- src/lib/es5.d.ts | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 478f78f772a07..54bb6859ae221 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -4277,20 +4277,34 @@ declare namespace Intl { supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; }; + type DateFormatNumericVerbosity = "numeric" | "2-digit"; + type DateFormatNameVerbosity = "long" | "short" | "narrow"; + interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; + /** output examples – numeric: "2020", 2-digit: "20" */ + year?: DateFormatNumericVerbosity; + /** output examples – numeric: "3", 2-digit: "03", long: "March", short: "Mar", narrow: "M" */ + month?: DateFormatNumericVerbosity | DateFormatNameVerbosity; + /** output examples – numeric: "2", 2-digit: "02" */ + day?: DateFormatNumericVerbosity; + /** output examples – numeric: "2", 2-digit: "02" */ + hour?: DateFormatNumericVerbosity; + /** output examples – numeric: "2", 2-digit: "02" */ + minute?: DateFormatNumericVerbosity; + /** output examples – numeric: "2", 2-digit: "02" */ + second?: DateFormatNumericVerbosity; + /** output examples – long: "Thursday", short: "Thu", narrow: "T" */ + weekday?: DateFormatNameVerbosity; + /** output examples – long: "Anno Domini", short: "AD", narrow "A" */ + era?: DateFormatNameVerbosity; + /** set to `true` to force 12-hour am/pm "dayPeriod" values, or `false` to force 24-hour time without */ hour12?: boolean; + /** output examples – long: "Pacific Daylight Time", short: "PDT" */ + timeZoneName?: "long" | "short"; + /** set to the timezone name you want to render date and time for, e g "UTC", "Europe/Rome" */ timeZone?: string; + localeMatcher?: "best fit" | "lookup"; + formatMatcher?: "best fit" | "basic"; } interface ResolvedDateTimeFormatOptions { From 5d2e09e01d0b13163f63704d90cd98e816b579c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sundstr=C3=B6m?= Date: Wed, 20 May 2020 17:35:26 -0700 Subject: [PATCH 2/2] chore: addressed feedback --- src/lib/es5.d.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 54bb6859ae221..0cdf015a26c4b 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -4277,26 +4277,23 @@ declare namespace Intl { supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; }; - type DateFormatNumericVerbosity = "numeric" | "2-digit"; - type DateFormatNameVerbosity = "long" | "short" | "narrow"; - interface DateTimeFormatOptions { /** output examples – numeric: "2020", 2-digit: "20" */ - year?: DateFormatNumericVerbosity; + year?: "numeric" | "2-digit"; /** output examples – numeric: "3", 2-digit: "03", long: "March", short: "Mar", narrow: "M" */ - month?: DateFormatNumericVerbosity | DateFormatNameVerbosity; + month?: "numeric" | "2-digit" | "long" | "short" | "narrow"; /** output examples – numeric: "2", 2-digit: "02" */ - day?: DateFormatNumericVerbosity; + day?: "numeric" | "2-digit"; /** output examples – numeric: "2", 2-digit: "02" */ - hour?: DateFormatNumericVerbosity; + hour?: "numeric" | "2-digit"; /** output examples – numeric: "2", 2-digit: "02" */ - minute?: DateFormatNumericVerbosity; + minute?: "numeric" | "2-digit"; /** output examples – numeric: "2", 2-digit: "02" */ - second?: DateFormatNumericVerbosity; + second?: "numeric" | "2-digit"; /** output examples – long: "Thursday", short: "Thu", narrow: "T" */ - weekday?: DateFormatNameVerbosity; + weekday?: "long" | "short" | "narrow"; /** output examples – long: "Anno Domini", short: "AD", narrow "A" */ - era?: DateFormatNameVerbosity; + era?: "long" | "short" | "narrow"; /** set to `true` to force 12-hour am/pm "dayPeriod" values, or `false` to force 24-hour time without */ hour12?: boolean; /** output examples – long: "Pacific Daylight Time", short: "PDT" */