Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/core/scripts/find-returns-not-return-type.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { glob, readFile } from 'node:fs/promises';

const cwd = new URL('../src/api/', import.meta.url);
const results: string[] = [];

for await (const file of glob('**/*.ts', { cwd })) {
const content = await readFile(new URL(file, cwd), { encoding: 'utf-8' });

const matches = content.matchAll(/as Promise<(?<returnType>\w+)>/g);

for (const match of matches) {
const returnType = match.groups!.returnType!;

if (!returnType.startsWith('REST') || !returnType.includes('Result')) {
results.push(`in file core/src/api/${file}: ${returnType}`);
}
}
}

if (results.length > 0) {
console.warn('Found return types that are not REST return types:');

for (const result of results) {
console.warn(` - ${result}`);
}
} else {
console.log('No return types that are not REST return types found');
}
4 changes: 1 addition & 3 deletions packages/core/src/api/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import {
type RESTPostAPIChannelMessageResult,
type RESTPostAPIChannelThreadsJSONBody,
type RESTPostAPIChannelThreadsResult,
type RESTPostAPIChannelWebhookJSONBody,
type RESTPostAPIChannelWebhookResult,
type RESTPostAPIGuildForumThreadsJSONBody,
type RESTPostAPISendSoundboardSoundResult,
type RESTPostAPISoundboardSendSoundJSONBody,
Expand Down Expand Up @@ -566,7 +564,7 @@ export class ChannelsAPI {
body,
reason,
signal,
}) as Promise<APIThreadChannel>;
}) as Promise<RESTPostAPIChannelThreadsResult>;
}

/**
Expand Down
Loading