From fd2fe34270ebd406d12a55f33b74028dec31cfd2 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:33:54 +0900 Subject: refactor8frontend9: anyを除去 (#16778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/utility/drive.ts | 2 +- .../src/utility/image-effector/ImageEffector.ts | 2 +- packages/frontend/src/utility/paginator.ts | 11 ++- packages/frontend/src/utility/stream-mock.ts | 81 ---------------------- .../src/utility/watermark/WatermarkRenderer.ts | 3 +- 5 files changed, 13 insertions(+), 86 deletions(-) delete mode 100644 packages/frontend/src/utility/stream-mock.ts (limited to 'packages/frontend/src/utility') diff --git a/packages/frontend/src/utility/drive.ts b/packages/frontend/src/utility/drive.ts index fb2825e7f7..64079d125a 100644 --- a/packages/frontend/src/utility/drive.ts +++ b/packages/frontend/src/utility/drive.ts @@ -124,7 +124,7 @@ export function uploadFile(file: File | Blob, options: { const driveFile = JSON.parse(ev.target.response); globalEvents.emit('driveFileCreated', driveFile); resolve(driveFile); - }) as (ev: ProgressEvent) => any; + }) as (ev: ProgressEvent) => void; if (options.onProgress) { xhr.upload.onprogress = ev => { diff --git a/packages/frontend/src/utility/image-effector/ImageEffector.ts b/packages/frontend/src/utility/image-effector/ImageEffector.ts index 9d5b961416..10d9d2e6bc 100644 --- a/packages/frontend/src/utility/image-effector/ImageEffector.ts +++ b/packages/frontend/src/utility/image-effector/ImageEffector.ts @@ -13,7 +13,7 @@ interface CommonParamDef { type: string; label?: string; caption?: string; - default: any; + default: unknown; } interface NumberParamDef extends CommonParamDef { diff --git a/packages/frontend/src/utility/paginator.ts b/packages/frontend/src/utility/paginator.ts index 7db55db7d6..59ae1e431a 100644 --- a/packages/frontend/src/utility/paginator.ts +++ b/packages/frontend/src/utility/paginator.ts @@ -5,7 +5,7 @@ import { ref, shallowRef, triggerRef } from 'vue'; import * as Misskey from 'misskey-js'; -import type { ComputedRef, Ref, ShallowRef } from 'vue'; +import type { ComputedRef, Ref, ShallowRef, UnwrapRef } from 'vue'; import { misskeyApi } from '@/utility/misskey-api.js'; const MAX_ITEMS = 30; @@ -19,7 +19,12 @@ export type MisskeyEntity = { _shouldInsertAd_?: boolean; }; -type FilterByEpRes> = { +type AbsEndpointType = { + req: unknown; + res: unknown; +}; + +type FilterByEpRes> = { [K in keyof E]: E[K]['res'] extends Array<{ id: string }> ? K : never }[keyof E]; export type PaginatorCompatibleEndpointPaths = FilterByEpRes; @@ -27,6 +32,8 @@ export type PaginatorCompatibleEndpoints = { [K in PaginatorCompatibleEndpointPaths]: Misskey.Endpoints[K]; }; +export type ExtractorFunction

= (item: UnwrapRef[number]) => T; + export interface IPaginator { /** * 外部から直接操作しないでください diff --git a/packages/frontend/src/utility/stream-mock.ts b/packages/frontend/src/utility/stream-mock.ts deleted file mode 100644 index 9b1b368de4..0000000000 --- a/packages/frontend/src/utility/stream-mock.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and misskey-project - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import { EventEmitter } from 'eventemitter3'; -import * as Misskey from 'misskey-js'; -import type { Channels, StreamEvents, IStream, IChannelConnection } from 'misskey-js'; - -type AnyOf> = T[keyof T]; -type OmitFirst = T extends [any, ...infer R] ? R : never; - -/** - * Websocket無効化時に使うStreamのモック(なにもしない) - */ -export class StreamMock extends EventEmitter implements IStream { - public readonly state = 'initializing'; - - constructor(...args: ConstructorParameters) { - super(); - // do nothing - } - - public useChannel(channel: C, params?: Channels[C]['params'], name?: string): ChannelConnectionMock { - return new ChannelConnectionMock(this, channel, name); - } - - public removeSharedConnection(connection: any): void { - // do nothing - } - - public removeSharedConnectionPool(pool: any): void { - // do nothing - } - - public disconnectToChannel(): void { - // do nothing - } - - public send(typeOrPayload: string): void; - public send(typeOrPayload: string, payload: any): void; - public send(typeOrPayload: Record | any[]): void; - public send(typeOrPayload: string | Record | any[], payload?: any): void { - // do nothing - } - - public ping(): void { - // do nothing - } - - public heartbeat(): void { - // do nothing - } - - public close(): void { - // do nothing - } -} - -class ChannelConnectionMock = any> extends EventEmitter implements IChannelConnection { - public id = ''; - public name?: string; // for debug - public inCount = 0; // for debug - public outCount = 0; // for debug - public channel: string; - - constructor(stream: IStream, ...args: OmitFirst>>) { - super(); - - this.channel = args[0]; - this.name = args[1]; - } - - public send(type: T, body: Channel['receives'][T]): void { - // do nothing - } - - public dispose(): void { - // do nothing - } -} diff --git a/packages/frontend/src/utility/watermark/WatermarkRenderer.ts b/packages/frontend/src/utility/watermark/WatermarkRenderer.ts index 766d45148a..32341a9e10 100644 --- a/packages/frontend/src/utility/watermark/WatermarkRenderer.ts +++ b/packages/frontend/src/utility/watermark/WatermarkRenderer.ts @@ -222,7 +222,8 @@ export class WatermarkRenderer { }, }); } else { - throw new Error(`Unrecognized layer type: ${(layer as any).type}`); + // @ts-expect-error Should be unreachable + throw new Error(`Unrecognized layer type: ${layer.type}`); } } -- cgit v1.2.3-freya