From e777feae9aba5e4c79afaa2a7d4e958da40084da Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 12 Sep 2021 15:53:04 +0900 Subject: [PATCH] fix lint --- src/misc/schema.ts | 2 +- src/server/api/stream/channels/home-timeline.ts | 3 ++- src/server/api/stream/types.ts | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/misc/schema.ts b/src/misc/schema.ts index f5e13d76d6..fbcedbf2ff 100644 --- a/src/misc/schema.ts +++ b/src/misc/schema.ts @@ -47,7 +47,7 @@ export const refs = { GalleryPost: packedGalleryPostSchema, }; -export type Packed = PackRef +export type Packed = PackRef; type PackRef = { [x in keyof s['properties']]: SchemaType }; diff --git a/src/server/api/stream/channels/home-timeline.ts b/src/server/api/stream/channels/home-timeline.ts index 0e21ab552e..5482ccbfcf 100644 --- a/src/server/api/stream/channels/home-timeline.ts +++ b/src/server/api/stream/channels/home-timeline.ts @@ -5,6 +5,7 @@ import { Notes } from '@/models/index'; import { PackedNote } from '@/models/repositories/note'; import { checkWordMute } from '@/misc/check-word-mute'; import { isBlockerUserRelated } from '@/misc/is-blocker-user-related'; +import { Packed } from '@/misc/schema'; export default class extends Channel { public readonly chName = 'homeTimeline'; @@ -18,7 +19,7 @@ export default class extends Channel { } @autobind - private async onNote(note: PackedNote) { + private async onNote(note: Packed<'Note'>) { if (note.channelId) { if (!this.followingChannels.has(note.channelId)) return; } else { diff --git a/src/server/api/stream/types.ts b/src/server/api/stream/types.ts index 7cb1213f21..c4cba3d857 100644 --- a/src/server/api/stream/types.ts +++ b/src/server/api/stream/types.ts @@ -6,7 +6,7 @@ import { UserProfile } from '@/models/entities/user-profile'; import { PackedUser } from '@/models/repositories/user'; import { PackedNotification } from '@/models/repositories/notification'; import { Note } from '@/models/entities/note'; -import { PackedNote } from '@/models/repositories/note'; +// import { Packed<'Note'> } from '@/models/repositories/note'; import { Antenna } from '@/models/entities/antenna'; import { DriveFile } from '@/models/entities/drive-file'; import { PackedDriveFile } from '@/models/repositories/drive-file'; @@ -24,6 +24,7 @@ import { PackedReversiMatching } from '@/models/repositories/games/reversi/match import { AbuseUserReport } from '@/models/entities/abuse-user-report'; import { PackedSignin } from '@/models/repositories/signin'; import { Page } from '@/models/entities/page'; +import { Packed } from '@/misc/schema'; // 辞書(interface or type)から{ type, body }ユニオンを定義 // https://stackoverflow.com/questions/49311989/can-i-infer-the-type-of-a-value-using-extends-keyof-type @@ -59,9 +60,9 @@ export interface UserStreamTypes { export interface MainStreamTypes { notification: PackedNotification; - mention: PackedNote; - reply: PackedNote; - renote: PackedNote; + mention: Packed<'Note'>; + reply: Packed<'Note'>; + renote: Packed<'Note'>; follow: PackedUser; followed: PackedUser; unfollow: PackedUser; @@ -288,7 +289,7 @@ export type StreamMessages = { }; notes: { name: 'notesStream'; - spec: PackedNote; + spec: Packed<'Note'>; }; };