This commit is contained in:
kakkokari-gtyih 2024-06-23 00:23:00 +09:00
parent 1736ee3837
commit e7b171d648
3 changed files with 382 additions and 394 deletions

View File

@ -290,12 +290,6 @@ async function generateApiClientJSDoc(
'',
' catch<TResult = never>(onrejected?: ((reason: TError) => TResult | PromiseLike<TResult>) | undefined | null): Promise<TSuccess | TResult>;',
'}',
'',
'class ErrPromise<TSuccess, TError> extends Promise<TSuccess> implements IErrPromise<TSuccess, TError> {',
' constructor(executor: (resolve: (value: TSuccess | PromiseLike<TSuccess>) => void, reject: (reason: TError) => void) => void) {',
' super(executor);',
' }',
'}',
);
endpointOutputLine.push('');
@ -312,7 +306,7 @@ async function generateApiClientJSDoc(
' endpoint: E,',
' params: P,',
' credential?: string | null,',
' ): ErrPromise<SwitchCaseResponseType<E, P>, RE>;',
' ): IErrPromise<SwitchCaseResponseType<E, P>, RE>;',
);
if (i < endpoints.length - 1) {

View File

@ -65,8 +65,8 @@ export class APIClient {
endpoint: E,
params: P = {} as P,
credential?: string | null,
): ErrPromise<SwitchCaseResponseType<E, P>, RE> {
return new Promise((resolve, reject) => {
): IErrPromise<SwitchCaseResponseType<E, P>, RE> {
return new ErrPromise((resolve, reject) => {
this.fetch(`${this.origin}/api/${endpoint}`, {
method: 'POST',
body: JSON.stringify({

File diff suppressed because it is too large Load Diff