Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type refactors (backend)? #20

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/backend/src/core/AiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AiService {
}

const buffer = await fs.promises.readFile(path);
const image = await tf.node.decodeImage(buffer, 3) as any;
const image = await tf.node.decodeImage(buffer, 3) as tf.Tensor3D;
try {
const predictions = await this.model.classify(image);
return predictions;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/CustomEmojiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
@bindThis
public async populateEmojis(emojiNames: string[], noteUserHost: string | null): Promise<Record<string, string>> {
const emojis = await Promise.all(emojiNames.map(x => this.populateEmoji(x, noteUserHost)));
const res = {} as any;
const res: {emojiNames: string[]} = {};
for (let i = 0; i < emojiNames.length; i++) {
if (emojis[i] != null) {
res[emojiNames[i]] = emojis[i];
Expand All @@ -373,7 +373,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
@bindThis
public async prefetchEmojis(emojis: { name: string; host: string | null; }[]): Promise<void> {
const notCachedEmojis = emojis.filter(emoji => this.cache.get(`${emoji.name} ${emoji.host}`) == null);
const emojisQuery: any[] = [];
const emojisQuery: [{ name: FindOperator<string>, host: string | null }] = [];
const hosts = new Set(notCachedEmojis.map(e => e.host));
for (const host of hosts) {
if (host == null) continue;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/DriveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type AddFileArgs = {
/** Comment */
comment?: string | null;
/** Folder ID */
folderId?: any;
folderId?: MiDriveFolder['id'] | null;
/** If set to true, forcibly upload the file even if there is a file with the same hash. */
force?: boolean;
/** Do not save file to local */
Expand Down Expand Up @@ -817,7 +817,7 @@ export class DriveService {
} as DeleteObjectCommandInput;

await this.s3Service.delete(meta, param);
} catch (err: any) {
} catch (err: unknown) {
if (err.name === 'NoSuchKey') {
this.deleteLogger.warn(`The object storage had no such key to delete: ${key}. Skipping this.`, err as Error);
return;
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ class MyCustomLogger implements Logger {
}

@bindThis
public logQuery(query: string, parameters?: any[]) {
public logQuery(query: string, parameters?: unknown) {
sqlLogger.info(this.highlight(query));
}

@bindThis
public logQueryError(error: string, query: string, parameters?: any[]) {
public logQueryError(error: string, query: string, parameters?: unknown) {
sqlLogger.error(this.highlight(query));
}

@bindThis
public logQuerySlow(time: number, query: string, parameters?: any[]) {
public logQuerySlow(time: number, query: string, parameters?: unknown) {
sqlLogger.warn(this.highlight(query));
}

Expand Down
Loading