diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-03-31 09:48:23 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-03-31 09:48:23 -0400 |
| commit | b0e908e6c69ccf5a71cbadabff021910ea4a4fbc (patch) | |
| tree | f8acdb7eb5dac44123e14227eb702a5268b04a3a | |
| parent | regenerate package-lock.yaml (diff) | |
| download | sharkey-b0e908e6c69ccf5a71cbadabff021910ea4a4fbc.tar.gz sharkey-b0e908e6c69ccf5a71cbadabff021910ea4a4fbc.tar.bz2 sharkey-b0e908e6c69ccf5a71cbadabff021910ea4a4fbc.zip | |
fix type errors from os.apiWithDialog
| -rw-r--r-- | packages/frontend/src/os.ts | 14 |
1 files 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<string, { title?: string; text: string; }>; -export const apiWithDialog = (<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req']>( +export const apiWithDialog = (< + ResT = void, + E extends Endpoint | NonNullable<string> = Endpoint, + P extends AnyRequest<E> = E extends Endpoint ? Request<E> : never, + _ResT = ResT extends void ? Response<E, P> : 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<ResT, E, P, _ResT>(endpoint, data, token); promiseDialog(promise, null, async (err) => { let title: string | undefined; let text = err.message + '\n' + err.id; |