diff --git a/packages/backend/src/GlobalModule.ts b/packages/backend/src/GlobalModule.ts index 6ae8ccfbb3..5d1de1c5f7 100644 --- a/packages/backend/src/GlobalModule.ts +++ b/packages/backend/src/GlobalModule.ts @@ -126,9 +126,9 @@ const $meta: Provider = { const { type, body } = obj.message as GlobalEvents['internal']['payload']; switch (type) { case 'metaUpdated': { - for (const key in body.after) { - (meta as any)[key] = (body.after as any)[key]; - } + Object.entries(body.after).forEach(([key, value]) => { + (meta as any)[key] = value + }) meta.proxyAccount = null; // joinなカラムは通常取ってこないので break; } diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 4bc5c799cf..fb3aaa163a 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -146,7 +146,7 @@ function loadConfigBoot(): Config { if (typeof exception === 'string') { configLogger.error(exception); process.exit(1); - } else if ((exception as any).code === 'ENOENT') { + } else if (exception && typeof exception === 'object' && 'code' in exception && exception.code === 'ENOENT') { configLogger.error('Configuration file not found', null, true); process.exit(1); } diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts index ad852fdd6e..9eb04e5986 100644 --- a/packages/backend/src/core/AiService.ts +++ b/packages/backend/src/core/AiService.ts @@ -11,6 +11,7 @@ import * as nsfw from 'nsfwjs'; import si from 'systeminformation'; import { Mutex } from 'async-mutex'; import { bindThis } from '@/decorators.js'; +import { Tensor3D } from '@tensorflow/tfjs-core'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -51,7 +52,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 Tensor3D; try { const predictions = await this.model.classify(image); return predictions; diff --git a/packages/backend/src/core/EmailService.ts b/packages/backend/src/core/EmailService.ts index da198d0e42..89c39a11c6 100644 --- a/packages/backend/src/core/EmailService.ts +++ b/packages/backend/src/core/EmailService.ts @@ -16,6 +16,7 @@ import type { MiMeta, UserProfilesRepository } from '@/models/_.js'; import { LoggerService } from '@/core/LoggerService.js'; import { bindThis } from '@/decorators.js'; import { HttpRequestService } from '@/core/HttpRequestService.js'; +import SMTPPool from 'nodemailer/lib/smtp-pool/index.js'; @Injectable() export class EmailService { @@ -48,6 +49,7 @@ export class EmailService { const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== ''; const transporter = nodemailer.createTransport({ + pool: true, host: this.meta.smtpHost, port: this.meta.smtpPort, secure: this.meta.smtpSecure, @@ -57,7 +59,7 @@ export class EmailService { user: this.meta.smtpUser, pass: this.meta.smtpPass, } : undefined, - } as any); + } as SMTPPool.Options); const htmlContent = ` diff --git a/packages/backend/src/core/HashtagService.ts b/packages/backend/src/core/HashtagService.ts index 793bbeecb1..3de5012618 100644 --- a/packages/backend/src/core/HashtagService.ts +++ b/packages/backend/src/core/HashtagService.ts @@ -68,7 +68,7 @@ export class HashtagService { const q = this.hashtagsRepository.createQueryBuilder('tag').update() .where('name = :name', { name: tag }); - const set = {} as any; + const set = {} as Record string>; if (isUserAttached) { if (inc) { diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 8061622340..6150bdd3f3 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -6,7 +6,7 @@ import { URL } from 'node:url'; import { Inject, Injectable } from '@nestjs/common'; import * as parse5 from 'parse5'; -import { Window, XMLSerializer } from 'happy-dom'; +import { HTMLElement, Text, Window, XMLSerializer } from 'happy-dom'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import { intersperse } from '@/misc/prelude/array.js'; @@ -245,9 +245,9 @@ export class MfmService { const body = doc.createElement('p'); - function appendChildren(children: mfm.MfmNode[], targetElement: any): void { + function appendChildren(children: mfm.MfmNode[], targetElement: HTMLElement): void { if (children) { - for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child); + for (const child of children.map(x => (handlers[x.type] as (node: mfm.NodeType) => HTMLElement | Text)(x))) targetElement.appendChild(child); } } @@ -257,7 +257,7 @@ export class MfmService { return el; } - const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType) => any } = { + const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType) => HTMLElement | Text} = { bold: (node) => { const el = doc.createElement('b'); appendChildren(node.children, el); diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 56ddcefd7c..58350d4489 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -57,6 +57,7 @@ import { trackPromise } from '@/misc/promise-tracker.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; import { CollapsedQueue } from '@/misc/collapsed-queue.js'; import { CacheService } from '@/core/CacheService.js'; +import { noteVisibilities } from '@/types.js'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -134,7 +135,7 @@ type Option = { localOnly?: boolean | null; reactionAcceptance?: MiNote['reactionAcceptance']; cw?: string | null; - visibility?: string; + visibility?: typeof noteVisibilities[number]; visibleUsers?: MinimumUser[] | null; channel?: MiChannel | null; apMentions?: MinimumUser[] | null; @@ -424,7 +425,7 @@ export class NoteCreateService implements OnApplicationShutdown { userId: user.id, localOnly: data.localOnly!, reactionAcceptance: data.reactionAcceptance, - visibility: data.visibility as any, + visibility: data.visibility, visibleUserIds: data.visibility === 'specified' ? data.visibleUsers ? data.visibleUsers.map(u => u.id) @@ -857,7 +858,7 @@ export class NoteCreateService implements OnApplicationShutdown { i === self.findIndex(u2 => u.id === u2.id), ); - return mentionedUsers; + return mentionedUsers.filter(mentionedUser => !!mentionedUser) as MiUser[]; } @bindThis diff --git a/packages/backend/src/core/NoteDeleteService.ts b/packages/backend/src/core/NoteDeleteService.ts index 4ecd2592b2..764d6eb3e7 100644 --- a/packages/backend/src/core/NoteDeleteService.ts +++ b/packages/backend/src/core/NoteDeleteService.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Brackets, In } from 'typeorm'; +import { Brackets, FindOptionsWhere, In } from 'typeorm'; import { Injectable, Inject } from '@nestjs/common'; import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js'; import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js'; @@ -165,7 +165,7 @@ export class NoteDeleteService { @bindThis private async getMentionedRemoteUsers(note: MiNote) { - const where = [] as any[]; + const where = [] as FindOptionsWhere[]; // mention / reply / dm const uris = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index 68ad92f396..616f69967a 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -153,7 +153,7 @@ export class NotificationService implements OnApplicationShutdown { notifierId, } : {}), ...data, - } as any as FilterUnionByProperty; + } as unknown as FilterUnionByProperty; const redisIdPromise = this.redisClient.xadd( `notificationTimeline:${notifieeId}`, diff --git a/packages/backend/src/core/PushNotificationService.ts b/packages/backend/src/core/PushNotificationService.ts index 1479bb00d9..512d79fd94 100644 --- a/packages/backend/src/core/PushNotificationService.ts +++ b/packages/backend/src/core/PushNotificationService.ts @@ -39,7 +39,7 @@ function truncateBody(type: T, body: Pus cw: undefined, reply: undefined, renote: undefined, - user: type === 'notification' ? undefined as any : body.note.user, + user: type === 'notification' ? undefined : body.note.user, }, } : {}), }; diff --git a/packages/backend/src/core/UserSuspendService.ts b/packages/backend/src/core/UserSuspendService.ts index 7920e58e36..fb0eea4a64 100644 --- a/packages/backend/src/core/UserSuspendService.ts +++ b/packages/backend/src/core/UserSuspendService.ts @@ -133,7 +133,7 @@ export class UserSuspendService { } for (const inbox of queue) { - this.queueService.deliver(user as any, content, inbox, true); + this.queueService.deliver(user, content, inbox, true); } } } diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 8590861ca0..c3b9b87e2e 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -390,10 +390,10 @@ export class ApPersonService implements OnModuleInit { uri: person.id, tags, isBot, - isCat: (person as any).isCat === true, - requireSigninToViewContents: (person as any).requireSigninToViewContents === true, - makeNotesFollowersOnlyBefore: (person as any).makeNotesFollowersOnlyBefore ?? null, - makeNotesHiddenBefore: (person as any).makeNotesHiddenBefore ?? null, + isCat: 'isCat' in person && person.isCat as boolean, + requireSigninToViewContents: 'requireSigninToViewContents' in person && person.requireSigninToViewContents as boolean, + makeNotesFollowersOnlyBefore: ('makeNotesFollowersOnlyBefore' in person && person.makeNotesFollowersOnlyBefore as number) || null, + makeNotesHiddenBefore: ('makeNotesHiddenBefore' in person && person.makeNotesHiddenBefore as number) || null, emojis, })) as MiRemoteUser; @@ -737,7 +737,7 @@ export class ApPersonService implements OnModuleInit { transactionalEntityManager.insert(MiUserNotePining, { id: this.idService.gen(Date.now() + td), userId: user.id, - noteId: note.id, + noteId: note?.id, }); } }); diff --git a/packages/backend/src/logger.ts b/packages/backend/src/logger.ts index ff5363a425..72ccaa7089 100644 --- a/packages/backend/src/logger.ts +++ b/packages/backend/src/logger.ts @@ -75,13 +75,13 @@ export default class Logger { } @bindThis - public error(x: string | Error, data?: Record | null, important = false): void { // 実行を継続できない状況で使う + public error(x: string | object | Error, data?: Record | null, important = false): void { // 実行を継続できない状況で使う if (x instanceof Error) { data = data ?? {}; data.e = x; this.log('error', x.toString(), data, important); } else if (typeof x === 'object') { - this.log('error', `${(x as any).message ?? (x as any).name ?? x}`, data, important); + this.log('error', `${('message' in x ? x.message : 'name' in x ? x.name : x)}`, data, important); } else { this.log('error', `${x}`, data, important); } diff --git a/packages/backend/test/e2e/clips.ts b/packages/backend/test/e2e/clips.ts index a130c3698d..42c050f455 100644 --- a/packages/backend/test/e2e/clips.ts +++ b/packages/backend/test/e2e/clips.ts @@ -647,7 +647,7 @@ describe('クリップ', () => { ...request, }, { status: 204, - }) as any as void; + }) as unknown as void; }; const removeNote = async (parameters: Misskey.entities.ClipsRemoveNoteRequest, request: Partial> = {}): Promise => { @@ -658,7 +658,7 @@ describe('クリップ', () => { ...request, }, { status: 204, - }) as any as void; + }) as unknown as void; }; const notes = async (parameters: Misskey.entities.ClipsNotesRequest, request: Partial> = {}): Promise => { diff --git a/packages/frontend-embed/src/misskey-api.ts b/packages/frontend-embed/src/misskey-api.ts index 0d3c679359..ccd57ffd9b 100644 --- a/packages/frontend-embed/src/misskey-api.ts +++ b/packages/frontend-embed/src/misskey-api.ts @@ -17,7 +17,7 @@ export function misskeyApi< _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, - data: P = {} as any, + data: P = {} as P, signal?: AbortSignal, ): Promise<_ResT> { if (endpoint.includes('://')) throw new Error('invalid endpoint'); @@ -64,7 +64,7 @@ export function misskeyApiGet< _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, - data: P = {} as any, + data: P = {} as P, ): Promise<_ResT> { pendingApiRequestsCount.value++; @@ -72,7 +72,7 @@ export function misskeyApiGet< pendingApiRequestsCount.value--; }; - const query = new URLSearchParams(data as any); + const query = new URLSearchParams(data); const promise = new Promise<_ResT>((resolve, reject) => { // Send request diff --git a/packages/frontend/.storybook/main.ts b/packages/frontend/.storybook/main.ts index 9f318cf449..f6e30536bb 100644 --- a/packages/frontend/.storybook/main.ts +++ b/packages/frontend/.storybook/main.ts @@ -43,7 +43,7 @@ const config = { plugins: [ { // XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8 - ...(turbosnap as any as typeof turbosnap['default'])({ + ...(turbosnap as unknown as typeof turbosnap['default'])({ rootDir: config.root ?? process.cwd(), }), name: 'fake-turbosnap', diff --git a/packages/frontend/src/scripts/misskey-api.ts b/packages/frontend/src/scripts/misskey-api.ts index e7a92e2d5c..1897505f6e 100644 --- a/packages/frontend/src/scripts/misskey-api.ts +++ b/packages/frontend/src/scripts/misskey-api.ts @@ -17,7 +17,7 @@ export function misskeyApi< _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, - data: P & { i?: string | null; } = {} as any, + data: P & { i?: string | null; } = {} as P, token?: string | null | undefined, signal?: AbortSignal, ): Promise<_ResT> { @@ -69,7 +69,7 @@ export function misskeyApiGet< _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, - data: P = {} as any, + data: P = {} as P, ): Promise<_ResT> { pendingApiRequestsCount.value++; @@ -77,7 +77,7 @@ export function misskeyApiGet< pendingApiRequestsCount.value--; }; - const query = new URLSearchParams(data as any); + const query = new URLSearchParams(data); const promise = new Promise<_ResT>((resolve, reject) => { // Send request diff --git a/packages/frontend/src/scripts/use-form.ts b/packages/frontend/src/scripts/use-form.ts index 0d505fe466..14eaf9c0b9 100644 --- a/packages/frontend/src/scripts/use-form.ts +++ b/packages/frontend/src/scripts/use-form.ts @@ -17,7 +17,7 @@ export function useForm>(initialState: T, save: (n const currentState = reactive(copy(initialState)); const previousState = reactive(copy(initialState)); - const modifiedStates = reactive>({} as any); + const modifiedStates = reactive | {}>({}); for (const key in currentState) { modifiedStates[key] = false; } diff --git a/packages/frontend/test/scroll.test.ts b/packages/frontend/test/scroll.test.ts index 32a5a1c558..adbf62dc42 100644 --- a/packages/frontend/test/scroll.test.ts +++ b/packages/frontend/test/scroll.test.ts @@ -18,7 +18,7 @@ describe('Scroll', () => { document.body.append(div); let called = false; - onScrollTop(div as any as HTMLElement, () => called = true); + onScrollTop(div as unknown as HTMLElement, () => called = true); assert.ok(called); }); @@ -30,7 +30,7 @@ describe('Scroll', () => { assert.strictEqual(div.scrollTop, 0); let called = false; - onScrollTop(div as any as HTMLElement, () => called = true); + onScrollTop(div as unknown as HTMLElement, () => called = true); assert.ok(!called); }); @@ -46,7 +46,7 @@ describe('Scroll', () => { document.body.append(div); let called = false; - onScrollBottom(div as any as HTMLElement, () => called = true); + onScrollBottom(div as unknown as HTMLElement, () => called = true); assert.ok(called); }); @@ -58,7 +58,7 @@ describe('Scroll', () => { assert.strictEqual(div.scrollTop, 0); let called = false; - onScrollBottom(div as any as HTMLElement, () => called = true); + onScrollBottom(div as unknown as HTMLElement, () => called = true); assert.ok(!called); }); diff --git a/packages/frontend/test/url-preview.test.ts b/packages/frontend/test/url-preview.test.ts index 4b79d33348..80e592b0ae 100644 --- a/packages/frontend/test/url-preview.test.ts +++ b/packages/frontend/test/url-preview.test.ts @@ -123,7 +123,7 @@ describe('MkUrlPreview', () => { url: 'https://example.local/player', width: null, height: null, - allow: undefined as any, + allow: [], }, }); assert.exists(iframe, 'iframe should exist');