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

[Re] refactor(misskey-js): 警告をすべて解決 #14277

Merged
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
1 change: 1 addition & 0 deletions packages/misskey-js/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tsParser from '@typescript-eslint/parser';
import sharedConfig from '../shared/eslint.config.js';

// eslint-disable-next-line import/no-default-export
export default [
...sharedConfig,
{
Expand Down
27 changes: 13 additions & 14 deletions packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ type Channel = components['schemas']['Channel'];
// Warning: (ae-forgotten-export) The symbol "AnyOf" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = any> extends EventEmitter<Channel['events']> {
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
constructor(stream: Stream, channel: string, name?: string);
// (undocumented)
channel: string;
Expand Down Expand Up @@ -771,12 +771,12 @@ export type Channels = {
user1: boolean;
user2: boolean;
}) => void;
updateSettings: (payload: {
updateSettings: <K extends ReversiUpdateKey>(payload: {
userId: User['id'];
key: string;
value: any;
key: K;
value: ReversiGameDetailed[K];
}) => void;
log: (payload: Record<string, any>) => void;
log: (payload: Record<string, unknown>) => void;
};
receives: {
putStone: {
Expand All @@ -785,10 +785,7 @@ export type Channels = {
};
ready: boolean;
cancel: null | Record<string, never>;
updateSettings: {
key: string;
value: any;
};
updateSettings: ReversiUpdateSettings<ReversiUpdateKey>;
claimTimeIsUp: null | Record<string, never>;
};
};
Expand Down Expand Up @@ -2730,7 +2727,7 @@ type PagesUnlikeRequest = operations['pages___unlike']['requestBody']['content']
type PagesUpdateRequest = operations['pages___update']['requestBody']['content']['application/json'];

// @public (undocumented)
function parse(acct: string): Acct;
function parse(_acct: string): Acct;

// Warning: (ae-forgotten-export) The symbol "Values" needs to be exported by the entry point index.d.ts
//
Expand Down Expand Up @@ -2969,7 +2966,7 @@ export class Stream extends EventEmitter<StreamEvents> {
constructor(origin: string, user: {
token: string;
} | null, options?: {
WebSocket?: any;
WebSocket?: WebSocket;
});
// (undocumented)
close(): void;
Expand All @@ -2992,9 +2989,9 @@ export class Stream extends EventEmitter<StreamEvents> {
// (undocumented)
send(typeOrPayload: string): void;
// (undocumented)
send(typeOrPayload: string, payload: any): void;
send(typeOrPayload: string, payload: unknown): void;
// (undocumented)
send(typeOrPayload: Record<string, any> | any[]): void;
send(typeOrPayload: Record<string, unknown> | unknown[]): void;
// (undocumented)
state: 'initializing' | 'reconnecting' | 'connected';
// (undocumented)
Expand Down Expand Up @@ -3229,7 +3226,9 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody']['

// Warnings were encountered during analysis:
//
// src/entities.ts:34:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/entities.ts:35:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
3 changes: 2 additions & 1 deletion packages/misskey-js/src/acct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export type Acct = {
host: string | null;
};

export function parse(acct: string): Acct {
export function parse(_acct: string): Acct {
let acct = _acct;
if (acct.startsWith('@')) acct = acct.substring(1);
const split = acct.split('@', 2);
return { username: split[0], host: split[1] || null };
Expand Down
3 changes: 3 additions & 0 deletions packages/misskey-js/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type APIError = {
code: string;
message: string;
kind: 'client' | 'server';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info: Record<string, any>;
};

Expand All @@ -29,6 +30,7 @@ export type FetchLike = (input: string, init?: {
headers: { [key in string]: string }
}) => Promise<{
status: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
json(): Promise<any>;
}>;

Expand All @@ -49,6 +51,7 @@ export class APIClient {
this.fetch = opts.fetch ?? ((...args) => fetch(...args));
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private assertIsRecord<T>(obj: T): obj is T & Record<string, any> {
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/misskey-js/src/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ type StrictExtract<Union, Cond> = Cond extends Union ? Union : never;

type IsCaseMatched<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
// eslint-disable-next-line @typescript-eslint/no-explicit-any
? IsNeverType<StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>> extends false ? true : false
: false

type GetCaseResult<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
// eslint-disable-next-line @typescript-eslint/no-explicit-any
? StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>[1]
: never

Expand Down
104 changes: 67 additions & 37 deletions packages/misskey-js/src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import type { operations } from './autogen/types.js';
import type {
AbuseReportNotificationRecipient, Ad,
Announcement,
EmojiDetailed, InviteCode,
MetaDetailed,
Note,
Role, SystemWebhook, UserLite,
} from './autogen/models.js';

export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'roleAssigned', 'achievementEarned'] as const;

export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;
Expand Down Expand Up @@ -135,10 +145,30 @@ export const moderationLogTypes = [
'unsetUserBanner',
] as const;

// See: packages/backend/src/core/ReversiService.ts@L410
export const reversiUpdateKeys = [
'map',
'bw',
'isLlotheo',
'canPutEverywhere',
'loopedBoard',
'timeLimitForEachTurn',
] as const;

export type ReversiUpdateKey = typeof reversiUpdateKeys[number];

type AvatarDecoration = UserLite['avatarDecorations'][number];

type ReceivedAbuseReport = {
reportId: AbuseReportNotificationRecipient['id'];
report: operations['admin___abuse-user-reports']['responses'][200]['content']['application/json'];
forwarded: boolean;
};

export type ModerationLogPayloads = {
updateServerSettings: {
before: any | null;
after: any | null;
before: MetaDetailed | null;
after: MetaDetailed | null;
};
suspend: {
userId: string;
Expand All @@ -159,16 +189,16 @@ export type ModerationLogPayloads = {
};
addCustomEmoji: {
emojiId: string;
emoji: any;
emoji: EmojiDetailed;
};
updateCustomEmoji: {
emojiId: string;
before: any;
after: any;
before: EmojiDetailed;
after: EmojiDetailed;
};
deleteCustomEmoji: {
emojiId: string;
emoji: any;
emoji: EmojiDetailed;
};
assignRole: {
userId: string;
Expand All @@ -187,16 +217,16 @@ export type ModerationLogPayloads = {
};
createRole: {
roleId: string;
role: any;
role: Role;
};
updateRole: {
roleId: string;
before: any;
after: any;
before: Role;
after: Role;
};
deleteRole: {
roleId: string;
role: any;
role: Role;
};
clearQueue: Record<string, never>;
promoteQueue: Record<string, never>;
Expand All @@ -211,39 +241,39 @@ export type ModerationLogPayloads = {
noteUserId: string;
noteUserUsername: string;
noteUserHost: string | null;
note: any;
note: Note;
};
createGlobalAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
};
createUserAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
};
updateGlobalAnnouncement: {
announcementId: string;
before: any;
after: any;
before: Announcement;
after: Announcement;
};
updateUserAnnouncement: {
announcementId: string;
before: any;
after: any;
before: Announcement;
after: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
};
deleteGlobalAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
};
deleteUserAnnouncement: {
announcementId: string;
announcement: any;
announcement: Announcement;
userId: string;
userUsername: string;
userHost: string | null;
Expand Down Expand Up @@ -281,37 +311,37 @@ export type ModerationLogPayloads = {
};
resolveAbuseReport: {
reportId: string;
report: any;
report: ReceivedAbuseReport;
forwarded: boolean;
};
createInvitation: {
invitations: any[];
invitations: InviteCode[];
};
createAd: {
adId: string;
ad: any;
ad: Ad;
};
updateAd: {
adId: string;
before: any;
after: any;
before: Ad;
after: Ad;
};
deleteAd: {
adId: string;
ad: any;
ad: Ad;
};
createAvatarDecoration: {
avatarDecorationId: string;
avatarDecoration: any;
avatarDecoration: AvatarDecoration;
};
updateAvatarDecoration: {
avatarDecorationId: string;
before: any;
after: any;
before: AvatarDecoration;
after: AvatarDecoration;
};
deleteAvatarDecoration: {
avatarDecorationId: string;
avatarDecoration: any;
avatarDecoration: AvatarDecoration;
};
unsetUserAvatar: {
userId: string;
Expand All @@ -327,28 +357,28 @@ export type ModerationLogPayloads = {
};
createSystemWebhook: {
systemWebhookId: string;
webhook: any;
webhook: SystemWebhook;
};
updateSystemWebhook: {
systemWebhookId: string;
before: any;
after: any;
before: SystemWebhook;
after: SystemWebhook;
};
deleteSystemWebhook: {
systemWebhookId: string;
webhook: any;
webhook: SystemWebhook;
};
createAbuseReportNotificationRecipient: {
recipientId: string;
recipient: any;
recipient: AbuseReportNotificationRecipient;
};
updateAbuseReportNotificationRecipient: {
recipientId: string;
before: any;
after: any;
before: AbuseReportNotificationRecipient;
after: AbuseReportNotificationRecipient;
};
deleteAbuseReportNotificationRecipient: {
recipientId: string;
recipient: any;
recipient: AbuseReportNotificationRecipient;
};
};
3 changes: 2 additions & 1 deletion packages/misskey-js/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Role,
RolePolicies,
User,
UserDetailedNotMe
UserDetailedNotMe,
} from './autogen/models.js';

export * from './autogen/entities.js';
Expand All @@ -19,6 +19,7 @@ export type DateString = string;
export type PageEvent = {
pageId: Page['id'];
event: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var: any;
userId: User['id'];
user: User;
Expand Down
Loading
Loading