1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 08:48:11 +09:00

fix type in CustomEmojiService 2

This commit is contained in:
tamaina 2023-04-12 12:32:27 +00:00
parent 6ea057f8f8
commit 3ff5a5ae29
2 changed files with 3 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import { MemoryKVCache, RedisSingleCache } from '@/misc/cache.js';
import { UtilityService } from '@/core/UtilityService.js';
import type { Config } from '@/config.js';
import { query } from '@/misc/prelude/url.js';
import { Serialized } from '@/server/api/stream/types';
@Injectable()
export class CustomEmojiService {
@ -46,7 +47,7 @@ export class CustomEmojiService {
toRedisConverter: (value) => JSON.stringify(Array.from(value.values())),
fromRedisConverter: (value) => {
if (!Array.isArray(JSON.parse(value))) return undefined; // 古いバージョンの壊れたキャッシュが残っていることがある(そのうち消す)
return new Map(JSON.parse(value).map((x: Emoji) => [x.name, {
return new Map(JSON.parse(value).map((x: Serialized<Emoji>) => [x.name, {
...x,
updatedAt: x.updatedAt && new Date(x.updatedAt),
}]));

View File

@ -172,7 +172,7 @@ type EventUnionFromDictionary<
> = U[keyof U];
// redis通すとDateのインスタンスはstringに変換されるので
type Serialized<T> = {
export type Serialized<T> = {
[K in keyof T]:
T[K] extends Date
? string