From a6ddcb7bd7421c606c3e4ca363a35f1c3623b134 Mon Sep 17 00:00:00 2001 From: Hoto Ras Date: Sat, 3 Aug 2024 19:22:55 +0900 Subject: [PATCH] Add some refactors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 타입 추정이 가능한데 대입이 안 돼있는 것들 타입 밀어넣음 --- packages/backend/src/core/AiService.ts | 2 +- packages/backend/src/core/CustomEmojiService.ts | 4 ++-- packages/backend/src/core/DriveService.ts | 4 ++-- packages/backend/src/postgres.ts | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts index 33b79be3557c..f8946ac6eb1a 100644 --- a/packages/backend/src/core/AiService.ts +++ b/packages/backend/src/core/AiService.ts @@ -56,7 +56,7 @@ export class AiService { } const buffer = await fs.promises.readFile(path); - const image = await tf.node.decodeImage(buffer, 3) as any; + const image = await tf.node.decodeImage(buffer, 3) as tf.Tensor3D; try { const predictions = await this.model.classify(image); return predictions; diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index feca0fe5e8c1..7a756f1a215c 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -358,7 +358,7 @@ export class CustomEmojiService implements OnApplicationShutdown { @bindThis public async populateEmojis(emojiNames: string[], noteUserHost: string | null): Promise> { const emojis = await Promise.all(emojiNames.map(x => this.populateEmoji(x, noteUserHost))); - const res = {} as any; + const res: {emojiNames: string[]} = {}; for (let i = 0; i < emojiNames.length; i++) { if (emojis[i] != null) { res[emojiNames[i]] = emojis[i]; @@ -373,7 +373,7 @@ export class CustomEmojiService implements OnApplicationShutdown { @bindThis public async prefetchEmojis(emojis: { name: string; host: string | null; }[]): Promise { const notCachedEmojis = emojis.filter(emoji => this.cache.get(`${emoji.name} ${emoji.host}`) == null); - const emojisQuery: any[] = []; + const emojisQuery: [{ name: FindOperator, host: string | null }] = []; const hosts = new Set(notCachedEmojis.map(e => e.host)); for (const host of hosts) { if (host == null) continue; diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index b15fbeaab83a..dd495978c5a9 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -54,7 +54,7 @@ type AddFileArgs = { /** Comment */ comment?: string | null; /** Folder ID */ - folderId?: any; + folderId?: MiDriveFolder['id'] | null; /** If set to true, forcibly upload the file even if there is a file with the same hash. */ force?: boolean; /** Do not save file to local */ @@ -817,7 +817,7 @@ export class DriveService { } as DeleteObjectCommandInput; await this.s3Service.delete(meta, param); - } catch (err: any) { + } catch (err: unknown) { if (err.name === 'NoSuchKey') { this.deleteLogger.warn(`The object storage had no such key to delete: ${key}. Skipping this.`, err as Error); return; diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index dfa5d86e127e..a784e133f0ee 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -104,17 +104,17 @@ class MyCustomLogger implements Logger { } @bindThis - public logQuery(query: string, parameters?: any[]) { + public logQuery(query: string, parameters?: unknown) { sqlLogger.info(this.highlight(query)); } @bindThis - public logQueryError(error: string, query: string, parameters?: any[]) { + public logQueryError(error: string, query: string, parameters?: unknown) { sqlLogger.error(this.highlight(query)); } @bindThis - public logQuerySlow(time: number, query: string, parameters?: any[]) { + public logQuerySlow(time: number, query: string, parameters?: unknown) { sqlLogger.warn(this.highlight(query)); }