From 54909304287f3c04dcfb39660be8ead57dc95440 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 24 May 2023 16:48:54 +0200 Subject: Remove suppressImplicitAnyIndexErrors It's deprecated by TS --- shared/core-utils/common/object.ts | 10 ++++++++++ shared/core-utils/i18n/i18n.ts | 4 ++-- shared/core-utils/renderer/html.ts | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'shared/core-utils') diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.ts index 9780b2594..1276bfcc7 100644 --- a/shared/core-utils/common/object.ts +++ b/shared/core-utils/common/object.ts @@ -23,10 +23,18 @@ function omit (object: O, keys: K[]): Excl return result } +function objectKeysTyped (object: O): K[] { + return (Object.keys(object) as K[]) +} + function getKeys (object: O, keys: K[]): K[] { return (Object.keys(object) as K[]).filter(k => keys.includes(k)) } +function hasKey (obj: T, k: keyof any): k is keyof T { + return k in obj +} + function sortObjectComparator (key: string, order: 'asc' | 'desc') { return (a: any, b: any) => { if (a[key] < b[key]) { @@ -69,7 +77,9 @@ function simpleObjectsDeepEqual (a: any, b: any) { export { pick, omit, + objectKeysTyped, getKeys, + hasKey, shallowCopy, sortObjectComparator, simpleObjectsDeepEqual diff --git a/shared/core-utils/i18n/i18n.ts b/shared/core-utils/i18n/i18n.ts index 38c1b0cc9..54b54077a 100644 --- a/shared/core-utils/i18n/i18n.ts +++ b/shared/core-utils/i18n/i18n.ts @@ -103,9 +103,9 @@ export function is18nLocale (locale: string) { export function getCompleteLocale (locale: string) { if (!locale) return locale - if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale] + const found = (I18N_LOCALE_ALIAS as any)[locale] as string - return locale + return found || locale } export function getShortLocale (locale: string) { diff --git a/shared/core-utils/renderer/html.ts b/shared/core-utils/renderer/html.ts index 877f2ec55..365bf7612 100644 --- a/shared/core-utils/renderer/html.ts +++ b/shared/core-utils/renderer/html.ts @@ -56,7 +56,7 @@ export function getCustomMarkupSanitizeOptions (additionalAllowedTags: string[] export function escapeHTML (stringParam: string) { if (!stringParam) return '' - const entityMap = { + const entityMap: { [id: string ]: string } = { '&': '&', '<': '<', '>': '>', -- cgit v1.2.3