Skip to content

Commit c7bd04e

Browse files
Revert "fix"
This reverts commit e8eb269.
1 parent 3245c90 commit c7bd04e

3 files changed

Lines changed: 3484 additions & 3482 deletions

File tree

packages/misskey-js/generator/src/generator.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function generateEndpoints(
204204

205205
async function generateApiClientJSDoc(
206206
openApiDocs: OpenAPIV3_1.Document,
207-
apiTypesFileName: string,
207+
apiClientFileName: string,
208208
endpointsFileName: string,
209209
warningsOutputPath: string,
210210
) {
@@ -238,29 +238,31 @@ async function generateApiClientJSDoc(
238238

239239
const endpointOutputLine: string[] = [];
240240

241-
endpointOutputLine.push(`import type { SwitchCaseResponseType } from '${toImportPath(apiTypesFileName)}';`);
241+
endpointOutputLine.push(`import type { SwitchCaseResponseType } from '${toImportPath(apiClientFileName)}';`);
242242
endpointOutputLine.push(`import type { Endpoints } from '${toImportPath(endpointsFileName)}';`);
243243
endpointOutputLine.push('');
244244

245-
endpointOutputLine.push('export interface APIClient {');
245+
endpointOutputLine.push(`declare module '${toImportPath(apiClientFileName)}' {`);
246+
endpointOutputLine.push(' export interface APIClient {');
246247
for (let i = 0; i < endpoints.length; i++) {
247248
const endpoint = endpoints[i];
248249

249250
endpointOutputLine.push(
250-
' /**',
251-
` * ${endpoint.description.split('\n').join('\n * ')}`,
252-
' */',
253-
` request<E extends '${endpoint.path}', P extends Endpoints[E][\'req\']>(`,
254-
' endpoint: E,',
255-
' params: P,',
256-
' credential?: string | null,',
257-
' ): Promise<SwitchCaseResponseType<E, P>>;',
251+
' /**',
252+
` * ${endpoint.description.split('\n').join('\n * ')}`,
253+
' */',
254+
` request<E extends '${endpoint.path}', P extends Endpoints[E][\'req\']>(`,
255+
' endpoint: E,',
256+
' params: P,',
257+
' credential?: string | null,',
258+
' ): Promise<SwitchCaseResponseType<E, P>>;',
258259
);
259260

260261
if (i < endpoints.length - 1) {
261262
endpointOutputLine.push('\n');
262263
}
263264
}
265+
endpointOutputLine.push(' }');
264266
endpointOutputLine.push('}');
265267
endpointOutputLine.push('');
266268

@@ -412,7 +414,7 @@ async function main() {
412414
await generateEndpoints(openApiDocs, typeFileName, entitiesFileName, endpointFileName);
413415

414416
const apiClientWarningFileName = `${generatePath}/apiClientJSDoc.ts`;
415-
await generateApiClientJSDoc(openApiDocs, '../api.types.ts', endpointFileName, apiClientWarningFileName);
417+
await generateApiClientJSDoc(openApiDocs, '../api.ts', endpointFileName, apiClientWarningFileName);
416418
}
417419

418420
main();

packages/misskey-js/src/api.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import './autogen/apiClientJSDoc.js';
2+
13
import { endpointReqTypes } from './autogen/endpoint.js';
2-
import type { APIClient as APIClientJSDoc } from './autogen/apiClientJSDoc.js';
34
import type { SwitchCaseResponseType, Endpoints } from './api.types.js';
45

56
export type {
@@ -126,6 +127,3 @@ export class APIClient {
126127
});
127128
}
128129
}
129-
130-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unsafe-declaration-merging
131-
export interface APIClient extends APIClientJSDoc {}

0 commit comments

Comments
 (0)