diff --git a/packages/common/src/i18n/format_date.ts b/packages/common/src/i18n/format_date.ts index df2294a339..cfb952c82b 100644 --- a/packages/common/src/i18n/format_date.ts +++ b/packages/common/src/i18n/format_date.ts @@ -270,6 +270,13 @@ function getDateTranslation( return getLocaleDayPeriods(locale, form, width)[currentHours < 12 ? 0 : 1]; case TranslationType.Eras: return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1]; + default: + // This default case is not needed by TypeScript compiler, as the switch is exhaustive. + // However Closure Compiler does not understand that and reports an error in typed mode. + // The `throw new Error` below works around the problem, and the unexpected: never variable + // makes sure tsc still checks this code is unreachable. + const unexpected: never = name; + throw new Error(`unexpected translation type ${unexpected}`); } }