From b0e908e6c69ccf5a71cbadabff021910ea4a4fbc Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 31 Mar 2025 09:48:23 -0400 Subject: [PATCH] fix type errors from os.apiWithDialog --- packages/frontend/src/os.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index fe7f7d9cb4..0023d07be8 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -15,6 +15,7 @@ import type { MenuItem } from '@/types/menu.js'; import type { PostFormProps } from '@/types/post-form.js'; import type MkRoleSelectDialog_TypeReferenceOnly from '@/components/MkRoleSelectDialog.vue'; import type MkEmojiPickerDialog_TypeReferenceOnly from '@/components/MkEmojiPickerDialog.vue'; +import type { AnyRequest, Endpoint, Request, Response } from '@/utility/misskey-api.js'; import { misskeyApi } from '@/utility/misskey-api.js'; import { prefer } from '@/preferences.js'; import { i18n } from '@/i18n.js'; @@ -34,13 +35,18 @@ import { focusParent } from '@/utility/focus.js'; export const openingWindowsCount = ref(0); export type ApiWithDialogCustomErrors = Record; -export const apiWithDialog = (( +export const apiWithDialog = (< + ResT = void, + E extends Endpoint | NonNullable = Endpoint, + P extends AnyRequest = E extends Endpoint ? Request : never, + _ResT = ResT extends void ? Response : ResT, +>( endpoint: E, - data: P, + data: P & { i?: string | null; } = {} as P & { i?: string | null; }, token?: string | null | undefined, customErrors?: ApiWithDialogCustomErrors, -) => { - const promise = misskeyApi(endpoint, data, token); +): Promise<_ResT> => { + const promise = misskeyApi(endpoint, data, token); promiseDialog(promise, null, async (err) => { let title: string | undefined; let text = err.message + '\n' + err.id;