Skip to content

Commit 48cf32c

Browse files
何故かうまく行かないので、とりあえずXORしてみる
1 parent e90854b commit 48cf32c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/backend/test/utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/val
1717
import { entities } from '../src/postgres.js';
1818
import { loadConfig } from '../src/config.js';
1919
import type * as misskey from 'misskey-js';
20+
import { ApiError } from "@/server/api/error.js";
2021

2122
export { server as startServer, jobQueue as startJobQueue } from '@/boot/common.js';
2223

@@ -66,10 +67,13 @@ export const failedApiCall = async <E extends keyof misskey.Endpoints, P extends
6667
return res.body;
6768
};
6869

70+
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
71+
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
72+
6973
export const api = async <E extends keyof misskey.Endpoints>(path: E, params: misskey.Endpoints[E]['req'], me?: UserToken): Promise<{
7074
status: number,
7175
headers: Headers,
72-
body: misskey.Endpoints[E]['res']
76+
body: XOR<misskey.Endpoints[E]['res'], { error: ApiError }>
7377
}> => {
7478
const bodyAuth: Record<string, string> = {};
7579
const headers: Record<string, string> = {

0 commit comments

Comments
 (0)