revert some changes

This commit is contained in:
kakkokari-gtyih 2024-10-16 19:19:07 +09:00
parent f6670da3f0
commit 1143504e00
1 changed files with 5 additions and 11 deletions

View File

@ -14,7 +14,6 @@ export function misskeyApi<
ResT = void, ResT = void,
E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints, E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints,
P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'], P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'],
ER extends Misskey.Endpoints[E]['errors'] = Misskey.Endpoints[E]['errors'],
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
@ -48,15 +47,13 @@ export function misskeyApi<
const body = res.status === 204 ? null : await res.json(); const body = res.status === 204 ? null : await res.json();
if (res.status === 200) { if (res.status === 200) {
resolve(body as _ResT); resolve(body);
} else if (res.status === 204) { } else if (res.status === 204) {
resolve(undefined as _ResT); // void -> undefined resolve(undefined as _ResT); // void -> undefined
} else { } else {
reject(new Misskey.api.APIError<ER>(body.error)); reject(body.error);
} }
}).catch((reason) => { }).catch(reject);
reject(new Error(reason));
});
}); });
promise.then(onFinally, onFinally); promise.then(onFinally, onFinally);
@ -69,7 +66,6 @@ export function misskeyApiGet<
ResT = void, ResT = void,
E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints, E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints,
P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'], P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'],
ER extends Misskey.Endpoints[E]['errors'] = Misskey.Endpoints[E]['errors'],
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
@ -97,11 +93,9 @@ export function misskeyApiGet<
} else if (res.status === 204) { } else if (res.status === 204) {
resolve(undefined as _ResT); // void -> undefined resolve(undefined as _ResT); // void -> undefined
} else { } else {
reject(new Misskey.api.APIError<ER>(body.error)); reject(body.error);
} }
}).catch((reason) => { }).catch(reject);
reject(new Error(reason));
});
}); });
promise.then(onFinally, onFinally); promise.then(onFinally, onFinally);