diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-24 16:48:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-24 16:56:05 +0200 |
commit | 54909304287f3c04dcfb39660be8ead57dc95440 (patch) | |
tree | 478f1b913f3bd4c3bbaa17525f0114c5b0a8689d /shared | |
parent | d0fbc9fd0a29c37f3ff9b99030351e90b276fe7d (diff) | |
download | PeerTube-54909304287f3c04dcfb39660be8ead57dc95440.tar.gz PeerTube-54909304287f3c04dcfb39660be8ead57dc95440.tar.zst PeerTube-54909304287f3c04dcfb39660be8ead57dc95440.zip |
Remove suppressImplicitAnyIndexErrors
It's deprecated by TS
Diffstat (limited to 'shared')
-rw-r--r-- | shared/core-utils/common/object.ts | 10 | ||||
-rw-r--r-- | shared/core-utils/i18n/i18n.ts | 4 | ||||
-rw-r--r-- | shared/core-utils/renderer/html.ts | 2 | ||||
-rw-r--r-- | shared/models/videos/playlist/video-exist-in-playlist.model.ts | 4 |
4 files changed, 15 insertions, 5 deletions
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 <O extends object, K extends keyof O> (object: O, keys: K[]): Excl | |||
23 | return result | 23 | return result |
24 | } | 24 | } |
25 | 25 | ||
26 | function objectKeysTyped <O extends object, K extends keyof O> (object: O): K[] { | ||
27 | return (Object.keys(object) as K[]) | ||
28 | } | ||
29 | |||
26 | function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] { | 30 | function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] { |
27 | return (Object.keys(object) as K[]).filter(k => keys.includes(k)) | 31 | return (Object.keys(object) as K[]).filter(k => keys.includes(k)) |
28 | } | 32 | } |
29 | 33 | ||
34 | function hasKey <T extends object> (obj: T, k: keyof any): k is keyof T { | ||
35 | return k in obj | ||
36 | } | ||
37 | |||
30 | function sortObjectComparator (key: string, order: 'asc' | 'desc') { | 38 | function sortObjectComparator (key: string, order: 'asc' | 'desc') { |
31 | return (a: any, b: any) => { | 39 | return (a: any, b: any) => { |
32 | if (a[key] < b[key]) { | 40 | if (a[key] < b[key]) { |
@@ -69,7 +77,9 @@ function simpleObjectsDeepEqual (a: any, b: any) { | |||
69 | export { | 77 | export { |
70 | pick, | 78 | pick, |
71 | omit, | 79 | omit, |
80 | objectKeysTyped, | ||
72 | getKeys, | 81 | getKeys, |
82 | hasKey, | ||
73 | shallowCopy, | 83 | shallowCopy, |
74 | sortObjectComparator, | 84 | sortObjectComparator, |
75 | simpleObjectsDeepEqual | 85 | 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) { | |||
103 | export function getCompleteLocale (locale: string) { | 103 | export function getCompleteLocale (locale: string) { |
104 | if (!locale) return locale | 104 | if (!locale) return locale |
105 | 105 | ||
106 | if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale] | 106 | const found = (I18N_LOCALE_ALIAS as any)[locale] as string |
107 | 107 | ||
108 | return locale | 108 | return found || locale |
109 | } | 109 | } |
110 | 110 | ||
111 | export function getShortLocale (locale: string) { | 111 | 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[] | |||
56 | export function escapeHTML (stringParam: string) { | 56 | export function escapeHTML (stringParam: string) { |
57 | if (!stringParam) return '' | 57 | if (!stringParam) return '' |
58 | 58 | ||
59 | const entityMap = { | 59 | const entityMap: { [id: string ]: string } = { |
60 | '&': '&', | 60 | '&': '&', |
61 | '<': '<', | 61 | '<': '<', |
62 | '>': '>', | 62 | '>': '>', |
diff --git a/shared/models/videos/playlist/video-exist-in-playlist.model.ts b/shared/models/videos/playlist/video-exist-in-playlist.model.ts index bc803a99c..6d06c0f4d 100644 --- a/shared/models/videos/playlist/video-exist-in-playlist.model.ts +++ b/shared/models/videos/playlist/video-exist-in-playlist.model.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | export type VideosExistInPlaylists = { | 1 | export type VideosExistInPlaylists = { |
2 | [videoId: number ]: VideoExistInPlaylist[] | 2 | [videoId: number]: VideoExistInPlaylist[] |
3 | } | 3 | } |
4 | export type CachedVideosExistInPlaylists = { | 4 | export type CachedVideosExistInPlaylists = { |
5 | [videoId: number ]: CachedVideoExistInPlaylist[] | 5 | [videoId: number]: CachedVideoExistInPlaylist[] |
6 | } | 6 | } |
7 | 7 | ||
8 | export type CachedVideoExistInPlaylist = { | 8 | export type CachedVideoExistInPlaylist = { |