mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 08:10:24 +01:00
refactor(types): delete any
not needed
This commit is contained in:
parent
f123be38b9
commit
a7ddadcb2d
20 changed files with 45 additions and 41 deletions
|
@ -126,9 +126,9 @@ const $meta: Provider = {
|
|||
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||
switch (type) {
|
||||
case 'metaUpdated': {
|
||||
for (const key in body.after) {
|
||||
(meta as any)[key] = (body.after as any)[key];
|
||||
}
|
||||
Object.entries(body.after).forEach(([key, value]) => {
|
||||
(meta as any)[key] = value
|
||||
})
|
||||
meta.proxyAccount = null; // joinなカラムは通常取ってこないので
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ function loadConfigBoot(): Config {
|
|||
if (typeof exception === 'string') {
|
||||
configLogger.error(exception);
|
||||
process.exit(1);
|
||||
} else if ((exception as any).code === 'ENOENT') {
|
||||
} else if (exception && typeof exception === 'object' && 'code' in exception && exception.code === 'ENOENT') {
|
||||
configLogger.error('Configuration file not found', null, true);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import * as nsfw from 'nsfwjs';
|
|||
import si from 'systeminformation';
|
||||
import { Mutex } from 'async-mutex';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { Tensor3D } from '@tensorflow/tfjs-core';
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
const _dirname = dirname(_filename);
|
||||
|
@ -51,7 +52,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 Tensor3D;
|
||||
try {
|
||||
const predictions = await this.model.classify(image);
|
||||
return predictions;
|
||||
|
|
|
@ -16,6 +16,7 @@ import type { MiMeta, UserProfilesRepository } from '@/models/_.js';
|
|||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import SMTPPool from 'nodemailer/lib/smtp-pool/index.js';
|
||||
|
||||
@Injectable()
|
||||
export class EmailService {
|
||||
|
@ -48,6 +49,7 @@ export class EmailService {
|
|||
const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== '';
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
pool: true,
|
||||
host: this.meta.smtpHost,
|
||||
port: this.meta.smtpPort,
|
||||
secure: this.meta.smtpSecure,
|
||||
|
@ -57,7 +59,7 @@ export class EmailService {
|
|||
user: this.meta.smtpUser,
|
||||
pass: this.meta.smtpPass,
|
||||
} : undefined,
|
||||
} as any);
|
||||
} as SMTPPool.Options);
|
||||
|
||||
const htmlContent = `<!doctype html>
|
||||
<html>
|
||||
|
|
|
@ -68,7 +68,7 @@ export class HashtagService {
|
|||
const q = this.hashtagsRepository.createQueryBuilder('tag').update()
|
||||
.where('name = :name', { name: tag });
|
||||
|
||||
const set = {} as any;
|
||||
const set = {} as Record<string, () => string>;
|
||||
|
||||
if (isUserAttached) {
|
||||
if (inc) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { URL } from 'node:url';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as parse5 from 'parse5';
|
||||
import { Window, XMLSerializer } from 'happy-dom';
|
||||
import { HTMLElement, Text, Window, XMLSerializer } from 'happy-dom';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import { intersperse } from '@/misc/prelude/array.js';
|
||||
|
@ -245,9 +245,9 @@ export class MfmService {
|
|||
|
||||
const body = doc.createElement('p');
|
||||
|
||||
function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
|
||||
function appendChildren(children: mfm.MfmNode[], targetElement: HTMLElement): void {
|
||||
if (children) {
|
||||
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child);
|
||||
for (const child of children.map(x => (handlers[x.type] as (node: mfm.NodeType<typeof x.type>) => HTMLElement | Text)(x))) targetElement.appendChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ export class MfmService {
|
|||
return el;
|
||||
}
|
||||
|
||||
const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => any } = {
|
||||
const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => HTMLElement | Text} = {
|
||||
bold: (node) => {
|
||||
const el = doc.createElement('b');
|
||||
appendChildren(node.children, el);
|
||||
|
|
|
@ -57,6 +57,7 @@ import { trackPromise } from '@/misc/promise-tracker.js';
|
|||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { CollapsedQueue } from '@/misc/collapsed-queue.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { noteVisibilities } from '@/types.js';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
|
@ -134,7 +135,7 @@ type Option = {
|
|||
localOnly?: boolean | null;
|
||||
reactionAcceptance?: MiNote['reactionAcceptance'];
|
||||
cw?: string | null;
|
||||
visibility?: string;
|
||||
visibility?: typeof noteVisibilities[number];
|
||||
visibleUsers?: MinimumUser[] | null;
|
||||
channel?: MiChannel | null;
|
||||
apMentions?: MinimumUser[] | null;
|
||||
|
@ -424,7 +425,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
userId: user.id,
|
||||
localOnly: data.localOnly!,
|
||||
reactionAcceptance: data.reactionAcceptance,
|
||||
visibility: data.visibility as any,
|
||||
visibility: data.visibility,
|
||||
visibleUserIds: data.visibility === 'specified'
|
||||
? data.visibleUsers
|
||||
? data.visibleUsers.map(u => u.id)
|
||||
|
@ -857,7 +858,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
i === self.findIndex(u2 => u.id === u2.id),
|
||||
);
|
||||
|
||||
return mentionedUsers;
|
||||
return mentionedUsers.filter(mentionedUser => !!mentionedUser) as MiUser[];
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Brackets, In } from 'typeorm';
|
||||
import { Brackets, FindOptionsWhere, In } from 'typeorm';
|
||||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||
import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js';
|
||||
|
@ -165,7 +165,7 @@ export class NoteDeleteService {
|
|||
|
||||
@bindThis
|
||||
private async getMentionedRemoteUsers(note: MiNote) {
|
||||
const where = [] as any[];
|
||||
const where = [] as FindOptionsWhere<MiUser>[];
|
||||
|
||||
// mention / reply / dm
|
||||
const uris = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri);
|
||||
|
|
|
@ -153,7 +153,7 @@ export class NotificationService implements OnApplicationShutdown {
|
|||
notifierId,
|
||||
} : {}),
|
||||
...data,
|
||||
} as any as FilterUnionByProperty<MiNotification, 'type', T>;
|
||||
} as unknown as FilterUnionByProperty<MiNotification, 'type', T>;
|
||||
|
||||
const redisIdPromise = this.redisClient.xadd(
|
||||
`notificationTimeline:${notifieeId}`,
|
||||
|
|
|
@ -39,7 +39,7 @@ function truncateBody<T extends keyof PushNotificationsTypes>(type: T, body: Pus
|
|||
cw: undefined,
|
||||
reply: undefined,
|
||||
renote: undefined,
|
||||
user: type === 'notification' ? undefined as any : body.note.user,
|
||||
user: type === 'notification' ? undefined : body.note.user,
|
||||
},
|
||||
} : {}),
|
||||
};
|
||||
|
|
|
@ -133,7 +133,7 @@ export class UserSuspendService {
|
|||
}
|
||||
|
||||
for (const inbox of queue) {
|
||||
this.queueService.deliver(user as any, content, inbox, true);
|
||||
this.queueService.deliver(user, content, inbox, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,10 +390,10 @@ export class ApPersonService implements OnModuleInit {
|
|||
uri: person.id,
|
||||
tags,
|
||||
isBot,
|
||||
isCat: (person as any).isCat === true,
|
||||
requireSigninToViewContents: (person as any).requireSigninToViewContents === true,
|
||||
makeNotesFollowersOnlyBefore: (person as any).makeNotesFollowersOnlyBefore ?? null,
|
||||
makeNotesHiddenBefore: (person as any).makeNotesHiddenBefore ?? null,
|
||||
isCat: 'isCat' in person && person.isCat as boolean,
|
||||
requireSigninToViewContents: 'requireSigninToViewContents' in person && person.requireSigninToViewContents as boolean,
|
||||
makeNotesFollowersOnlyBefore: ('makeNotesFollowersOnlyBefore' in person && person.makeNotesFollowersOnlyBefore as number) || null,
|
||||
makeNotesHiddenBefore: ('makeNotesHiddenBefore' in person && person.makeNotesHiddenBefore as number) || null,
|
||||
emojis,
|
||||
})) as MiRemoteUser;
|
||||
|
||||
|
@ -737,7 +737,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
transactionalEntityManager.insert(MiUserNotePining, {
|
||||
id: this.idService.gen(Date.now() + td),
|
||||
userId: user.id,
|
||||
noteId: note.id,
|
||||
noteId: note?.id,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -75,13 +75,13 @@ export default class Logger {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public error(x: string | Error, data?: Record<string, any> | null, important = false): void { // 実行を継続できない状況で使う
|
||||
public error(x: string | object | Error, data?: Record<string, any> | null, important = false): void { // 実行を継続できない状況で使う
|
||||
if (x instanceof Error) {
|
||||
data = data ?? {};
|
||||
data.e = x;
|
||||
this.log('error', x.toString(), data, important);
|
||||
} else if (typeof x === 'object') {
|
||||
this.log('error', `${(x as any).message ?? (x as any).name ?? x}`, data, important);
|
||||
this.log('error', `${('message' in x ? x.message : 'name' in x ? x.name : x)}`, data, important);
|
||||
} else {
|
||||
this.log('error', `${x}`, data, important);
|
||||
}
|
||||
|
|
|
@ -647,7 +647,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as unknown as void;
|
||||
};
|
||||
|
||||
const removeNote = async (parameters: Misskey.entities.ClipsRemoveNoteRequest, request: Partial<ApiRequest<'clips/remove-note'>> = {}): Promise<void> => {
|
||||
|
@ -658,7 +658,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as unknown as void;
|
||||
};
|
||||
|
||||
const notes = async (parameters: Misskey.entities.ClipsNotesRequest, request: Partial<ApiRequest<'clips/notes'>> = {}): Promise<Misskey.entities.Note[]> => {
|
||||
|
|
|
@ -17,7 +17,7 @@ export function misskeyApi<
|
|||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P = {} as any,
|
||||
data: P = {} as P,
|
||||
signal?: AbortSignal,
|
||||
): Promise<_ResT> {
|
||||
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
||||
|
@ -64,7 +64,7 @@ export function misskeyApiGet<
|
|||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P = {} as any,
|
||||
data: P = {} as P,
|
||||
): Promise<_ResT> {
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
|
@ -72,7 +72,7 @@ export function misskeyApiGet<
|
|||
pendingApiRequestsCount.value--;
|
||||
};
|
||||
|
||||
const query = new URLSearchParams(data as any);
|
||||
const query = new URLSearchParams(data);
|
||||
|
||||
const promise = new Promise<_ResT>((resolve, reject) => {
|
||||
// Send request
|
||||
|
|
|
@ -43,7 +43,7 @@ const config = {
|
|||
plugins: [
|
||||
{
|
||||
// XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8
|
||||
...(turbosnap as any as typeof turbosnap['default'])({
|
||||
...(turbosnap as unknown as typeof turbosnap['default'])({
|
||||
rootDir: config.root ?? process.cwd(),
|
||||
}),
|
||||
name: 'fake-turbosnap',
|
||||
|
|
|
@ -17,7 +17,7 @@ export function misskeyApi<
|
|||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P & { i?: string | null; } = {} as any,
|
||||
data: P & { i?: string | null; } = {} as P,
|
||||
token?: string | null | undefined,
|
||||
signal?: AbortSignal,
|
||||
): Promise<_ResT> {
|
||||
|
@ -69,7 +69,7 @@ export function misskeyApiGet<
|
|||
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
|
||||
>(
|
||||
endpoint: E,
|
||||
data: P = {} as any,
|
||||
data: P = {} as P,
|
||||
): Promise<_ResT> {
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
|
@ -77,7 +77,7 @@ export function misskeyApiGet<
|
|||
pendingApiRequestsCount.value--;
|
||||
};
|
||||
|
||||
const query = new URLSearchParams(data as any);
|
||||
const query = new URLSearchParams(data);
|
||||
|
||||
const promise = new Promise<_ResT>((resolve, reject) => {
|
||||
// Send request
|
||||
|
|
|
@ -17,7 +17,7 @@ export function useForm<T extends Record<string, any>>(initialState: T, save: (n
|
|||
const currentState = reactive<T>(copy(initialState));
|
||||
const previousState = reactive<T>(copy(initialState));
|
||||
|
||||
const modifiedStates = reactive<Record<keyof T, boolean>>({} as any);
|
||||
const modifiedStates = reactive<Record<keyof T, boolean> | {}>({});
|
||||
for (const key in currentState) {
|
||||
modifiedStates[key] = false;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('Scroll', () => {
|
|||
document.body.append(div);
|
||||
|
||||
let called = false;
|
||||
onScrollTop(div as any as HTMLElement, () => called = true);
|
||||
onScrollTop(div as unknown as HTMLElement, () => called = true);
|
||||
|
||||
assert.ok(called);
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ describe('Scroll', () => {
|
|||
assert.strictEqual(div.scrollTop, 0);
|
||||
|
||||
let called = false;
|
||||
onScrollTop(div as any as HTMLElement, () => called = true);
|
||||
onScrollTop(div as unknown as HTMLElement, () => called = true);
|
||||
|
||||
assert.ok(!called);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ describe('Scroll', () => {
|
|||
document.body.append(div);
|
||||
|
||||
let called = false;
|
||||
onScrollBottom(div as any as HTMLElement, () => called = true);
|
||||
onScrollBottom(div as unknown as HTMLElement, () => called = true);
|
||||
|
||||
assert.ok(called);
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ describe('Scroll', () => {
|
|||
assert.strictEqual(div.scrollTop, 0);
|
||||
|
||||
let called = false;
|
||||
onScrollBottom(div as any as HTMLElement, () => called = true);
|
||||
onScrollBottom(div as unknown as HTMLElement, () => called = true);
|
||||
|
||||
assert.ok(!called);
|
||||
});
|
||||
|
|
|
@ -123,7 +123,7 @@ describe('MkUrlPreview', () => {
|
|||
url: 'https://example.local/player',
|
||||
width: null,
|
||||
height: null,
|
||||
allow: undefined as any,
|
||||
allow: [],
|
||||
},
|
||||
});
|
||||
assert.exists(iframe, 'iframe should exist');
|
||||
|
|
Loading…
Reference in a new issue