From ed9b9210a9bec4549b7810acaab2b5c995c6ddf7 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 19 Mar 2023 10:45:57 +0100 Subject: [PATCH] server: remove some casting to any --- .../src/server/api/stream/channels/index.ts | 32 +++++++++---------- .../backend/src/server/api/stream/index.ts | 8 ++--- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/backend/src/server/api/stream/channels/index.ts b/packages/backend/src/server/api/stream/channels/index.ts index d422edde8..69aa50de1 100644 --- a/packages/backend/src/server/api/stream/channels/index.ts +++ b/packages/backend/src/server/api/stream/channels/index.ts @@ -14,20 +14,20 @@ import hashtag from './hashtag.js'; import channel from './channel.js'; import admin from './admin.js'; -export default { - main, - homeTimeline, - localTimeline, - hybridTimeline, - globalTimeline, - serverStats, - queueStats, - userList, - antenna, - messaging, - messagingIndex, - drive, - hashtag, - channel, - admin, +export const channels: Record = { + 'main': main, + 'homeTimeline': homeTimeline, + 'localTimeline': localTimeline, + 'hybridTimeline': hybridTimeline, + 'globalTimeline': globalTimeline, + 'serverStats': serverStats, + 'queueStats': queueStats, + 'userList': userList, + 'antenna': antenna, + 'messaging': messaging, + 'messagingIndex': messagingIndex, + 'drive': drive, + 'hashtag': hashtag, + 'channel': channel, + 'admin': admin, }; diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index 1c26fa8be..6e49fe847 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -10,7 +10,7 @@ import { publishChannelStream, publishGroupMessagingStream, publishMessagingStre import { UserGroup } from '@/models/entities/user-group.js'; import { Packed } from '@/misc/schema.js'; import { readNotification } from '@/server/api/common/read-notification.js'; -import channels from './channels/index.js'; +import { channels } from './channels/index.js'; import Channel from './channel.js'; import { StreamEventEmitter, StreamMessages } from './types.js'; import Logger from '@/services/logger.js'; @@ -290,16 +290,16 @@ export class Connection { * チャンネルに接続 */ public connectChannel(id: string, params: any, channel: string, pong = false) { - if ((channels as any)[channel].requireCredential && this.user == null) { + if (channels[channel].requireCredential && this.user == null) { return; } // 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視 - if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) { + if (channels[channel].shouldShare && this.channels.some(c => c.chName === channel)) { return; } - const ch: Channel = new (channels as any)[channel](id, this); + const ch: Channel = new channels[channel](id, this); this.channels.push(ch); ch.init(params);