diff --git a/src/core/account.ts b/src/core/account.ts index 860fcb4f..28342c7b 100644 --- a/src/core/account.ts +++ b/src/core/account.ts @@ -70,7 +70,7 @@ export class AccountCategory implements TypeAndName { return AccountCategory.allInstances; } - public static valueOf(type: number): AccountCategory { + public static valueOf(type: number): AccountCategory | undefined { return AccountCategory.allInstancesByType[type]; } } diff --git a/src/core/color.ts b/src/core/color.ts index 165b5cbc..fae78d7f 100644 --- a/src/core/color.ts +++ b/src/core/color.ts @@ -47,7 +47,7 @@ export class PresetAmountColor implements TypeAndName { return PresetAmountColor.allInstances; } - public static valueOf(type: number): PresetAmountColor { + public static valueOf(type: number): PresetAmountColor | undefined { return PresetAmountColor.allInstancesByType[type]; } } diff --git a/src/core/currency.ts b/src/core/currency.ts index 6ec7350f..95788d28 100644 --- a/src/core/currency.ts +++ b/src/core/currency.ts @@ -64,11 +64,11 @@ export class CurrencyDisplayType implements TypeAndName { return CurrencyDisplayType.allInstances; } - public static valueOf(type: number): CurrencyDisplayType { + public static valueOf(type: number): CurrencyDisplayType | undefined { return CurrencyDisplayType.allInstancesByType[type]; } - public static parse(typeName: string): CurrencyDisplayType { + public static parse(typeName: string): CurrencyDisplayType | undefined { return CurrencyDisplayType.allInstancesByTypeName[typeName]; } } diff --git a/src/core/datetime.ts b/src/core/datetime.ts index fef0135a..a8d09e94 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -160,7 +160,7 @@ export class Month { return Month.allInstances; } - public static valueOf(month: number): Month { + public static valueOf(month: number): Month | undefined { return Month.allInstances[month - 1]; } } @@ -194,11 +194,11 @@ export class WeekDay implements TypeAndName { return WeekDay.allInstances; } - public static valueOf(dayOfWeek: number): WeekDay { + public static valueOf(dayOfWeek: number): WeekDay | undefined { return WeekDay.allInstances[dayOfWeek]; } - public static parse(typeName: string): WeekDay { + public static parse(typeName: string): WeekDay | undefined { return WeekDay.allInstancesByName[typeName]; } } @@ -269,7 +269,7 @@ export class LongDateFormat implements DateFormat { return LongDateFormat.allInstancesByTypeName; } - public static valueOf(type: number): LongDateFormat { + public static valueOf(type: number): LongDateFormat | undefined { return LongDateFormat.allInstancesByType[type]; } } @@ -309,7 +309,7 @@ export class ShortDateFormat implements DateFormat { return ShortDateFormat.allInstancesByTypeName; } - public static valueOf(type: number): ShortDateFormat { + public static valueOf(type: number): ShortDateFormat | undefined { return ShortDateFormat.allInstancesByType[type]; } } @@ -360,7 +360,7 @@ export class LongTimeFormat implements TimeFormat { return LongTimeFormat.allInstancesByTypeName; } - public static valueOf(type: number): LongTimeFormat { + public static valueOf(type: number): LongTimeFormat | undefined { return LongTimeFormat.allInstancesByType[type]; } } @@ -404,7 +404,7 @@ export class ShortTimeFormat implements TimeFormat { return ShortTimeFormat.allInstancesByTypeName; } - public static valueOf(type: number): ShortTimeFormat { + public static valueOf(type: number): ShortTimeFormat | undefined { return ShortTimeFormat.allInstancesByType[type]; } } @@ -496,7 +496,7 @@ export class DateRange implements TypeAndName { return DateRange.allInstancesByTypeName; } - public static valueOf(type: number): DateRange { + public static valueOf(type: number): DateRange | undefined { return DateRange.allInstancesByType[type]; } diff --git a/src/core/numeral.ts b/src/core/numeral.ts index 0789dae8..d644fe99 100644 --- a/src/core/numeral.ts +++ b/src/core/numeral.ts @@ -56,11 +56,11 @@ export class DecimalSeparator implements TypeAndName, NumeralSymbolType { return DecimalSeparator.allInstances; } - public static valueOf(type: number): DecimalSeparator { + public static valueOf(type: number): DecimalSeparator | undefined { return DecimalSeparator.allInstancesByType[type]; } - public static parse(typeName: string): DecimalSeparator { + public static parse(typeName: string): DecimalSeparator | undefined { return DecimalSeparator.allInstancesByTypeName[typeName]; } } @@ -96,11 +96,11 @@ export class DigitGroupingSymbol implements TypeAndName, NumeralSymbolType { return DigitGroupingSymbol.allInstances; } - public static valueOf(type: number): DigitGroupingSymbol { + public static valueOf(type: number): DigitGroupingSymbol | undefined { return DigitGroupingSymbol.allInstancesByType[type]; } - public static parse(typeName: string): DigitGroupingSymbol { + public static parse(typeName: string): DigitGroupingSymbol | undefined { return DigitGroupingSymbol.allInstancesByTypeName[typeName]; } } @@ -136,11 +136,11 @@ export class DigitGroupingType implements TypeAndName { return DigitGroupingType.allInstances; } - public static valueOf(type: number): DigitGroupingType { + public static valueOf(type: number): DigitGroupingType | undefined { return DigitGroupingType.allInstancesByType[type]; } - public static parse(typeName: string): DigitGroupingType { + public static parse(typeName: string): DigitGroupingType | undefined { return DigitGroupingType.allInstancesByTypeName[typeName]; } } @@ -173,7 +173,7 @@ export class AmountFilterType { return AmountFilterType.allInstances; } - public static valueOf(type: string): AmountFilterType { + public static valueOf(type: string): AmountFilterType | undefined { return AmountFilterType.allInstancesByType[type]; } } diff --git a/src/core/statistics.ts b/src/core/statistics.ts index e4ddcd47..c6a4a57b 100644 --- a/src/core/statistics.ts +++ b/src/core/statistics.ts @@ -139,7 +139,7 @@ export class ChartDataType implements TypeAndName { return ChartDataType.allInstancesByTypeName; } - public static valueOf(type: number): ChartDataType { + public static valueOf(type: number): ChartDataType | undefined { return ChartDataType.allInstancesByType[type]; } @@ -176,7 +176,7 @@ export class ChartSortingType implements TypeAndName { return ChartSortingType.allInstances; } - public static valueOf(type: number): ChartSortingType { + public static valueOf(type: number): ChartSortingType | undefined { return ChartSortingType.allInstancesByType[type]; } } @@ -206,7 +206,7 @@ export class ChartDateAggregationType implements TypeAndName { return ChartDateAggregationType.allInstances; } - public static valueOf(type: number): ChartDateAggregationType { + public static valueOf(type: number): ChartDateAggregationType | undefined { return ChartDateAggregationType.allInstancesByType[type]; } } diff --git a/src/core/template.ts b/src/core/template.ts index 9e600a7d..54b306e8 100644 --- a/src/core/template.ts +++ b/src/core/template.ts @@ -30,7 +30,7 @@ export class TemplateType implements TypeAndName { return TemplateType.allInstancesByTypeName; } - public static valueOf(type: number): TemplateType { + public static valueOf(type: number): TemplateType | undefined { return TemplateType.allInstancesByType[type]; } } @@ -66,7 +66,7 @@ export class ScheduledTemplateFrequencyType implements TypeAndName { return ScheduledTemplateFrequencyType.allInstancesByTypeName; } - public static valueOf(type: number): ScheduledTemplateFrequencyType { + public static valueOf(type: number): ScheduledTemplateFrequencyType | undefined { return ScheduledTemplateFrequencyType.allInstancesByType[type]; } } diff --git a/src/lib/datetime.ts b/src/lib/datetime.ts index 2e7b8859..c2fcac71 100644 --- a/src/lib/datetime.ts +++ b/src/lib/datetime.ts @@ -237,12 +237,12 @@ export function getDay(date: SupportedDate): number { export function getDayOfWeekName(date: SupportedDate): string { const dayOfWeek = moment(date).days(); - return WeekDay.valueOf(dayOfWeek).name; + return (WeekDay.valueOf(dayOfWeek) as WeekDay).name; } export function getMonthName(date: SupportedDate): string { const month = moment(date).month(); - return Month.valueOf(month + 1).name; + return (Month.valueOf(month + 1) as Month).name; } export function getAMOrPM(hour: number): string { diff --git a/src/locales/helpers.ts b/src/locales/helpers.ts index 3e0445fd..64c58bae 100644 --- a/src/locales/helpers.ts +++ b/src/locales/helpers.ts @@ -328,8 +328,8 @@ export function useI18n() { return ret; } - function getLocalizedNumeralSeparatorFormats(allSeparatorArray: T[], localeDefaultType: T, systemDefaultType: T, languageDefaultValue: number): LocalizedNumeralSymbolType[] { - let defaultSeparatorType: T = localeDefaultType; + function getLocalizedNumeralSeparatorFormats(allSeparatorArray: T[], localeDefaultType: T | undefined, systemDefaultType: T, languageDefaultValue: number): LocalizedNumeralSymbolType[] { + let defaultSeparatorType: T | undefined = localeDefaultType; if (!defaultSeparatorType) { defaultSeparatorType = systemDefaultType; @@ -431,10 +431,10 @@ export function useI18n() { function getNumberFormatOptions(currencyCode?: string): NumberFormatOptions { return { - decimalSeparator: getCurrentDecimalSeparator(userStore.currentUserDecimalSeparator), + decimalSeparator: getCurrentDecimalSeparator(), decimalNumberCount: getCurrencyFraction(currencyCode), - digitGroupingSymbol: getCurrentDigitGroupingSymbol(userStore.currentUserDigitGroupingSymbol), - digitGrouping: getCurrentDigitGroupingType(userStore.currentUserDigitGrouping), + digitGroupingSymbol: getCurrentDigitGroupingSymbol(), + digitGrouping: getCurrentDigitGroupingType(), }; } @@ -803,8 +803,8 @@ export function useI18n() { return joinMultiText(finalWeekdayNames); } - function getCurrentDecimalSeparator(decimalSeparator: number): string { - let decimalSeparatorType = DecimalSeparator.valueOf(decimalSeparator); + function getCurrentDecimalSeparator(): string { + let decimalSeparatorType = DecimalSeparator.valueOf(userStore.currentUserDecimalSeparator); if (!decimalSeparatorType) { const defaultDecimalSeparatorTypeName = t('default.decimalSeparator'); @@ -818,8 +818,8 @@ export function useI18n() { return decimalSeparatorType.symbol; } - function getCurrentDigitGroupingSymbol(digitGroupingSymbol: number): string { - let digitGroupingSymbolType = DigitGroupingSymbol.valueOf(digitGroupingSymbol); + function getCurrentDigitGroupingSymbol(): string { + let digitGroupingSymbolType = DigitGroupingSymbol.valueOf(userStore.currentUserDigitGroupingSymbol); if (!digitGroupingSymbolType) { const defaultDigitGroupingSymbolTypeName = t('default.digitGroupingSymbol'); @@ -833,8 +833,8 @@ export function useI18n() { return digitGroupingSymbolType.symbol; } - function getCurrentDigitGroupingType(digitGrouping: number): number { - let digitGroupingType = DigitGroupingType.valueOf(digitGrouping); + function getCurrentDigitGroupingType(): number { + let digitGroupingType = DigitGroupingType.valueOf(userStore.currentUserDigitGrouping); if (!digitGroupingType) { const defaultDigitGroupingTypeName = t('default.digitGrouping'); @@ -897,7 +897,7 @@ export function useI18n() { return parseAmount(value, numberFormatOptions); } - function getFormattedAmount(value: number | string, currencyCode: string): string { + function getFormattedAmount(value: number | string, currencyCode?: string): string { const numberFormatOptions = getNumberFormatOptions(currencyCode); return formatAmount(value, numberFormatOptions); } @@ -1007,7 +1007,7 @@ export function useI18n() { let defaultFirstDayOfWeek = WeekDay.DefaultFirstDay.type; if (WeekDay.parse(defaultFirstDayOfWeekName)) { - defaultFirstDayOfWeek = WeekDay.parse(defaultFirstDayOfWeekName).type; + defaultFirstDayOfWeek = (WeekDay.parse(defaultFirstDayOfWeekName) as WeekDay).type; } return {