refactor: fix types

This commit is contained in:
syuilo 2023-02-09 11:46:08 +09:00
parent 33c4e57994
commit 76faec2115
4 changed files with 5 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { CreateNotificationService } from '@/core/CreateNotificationService.js'; import { CreateNotificationService } from '@/core/CreateNotificationService.js';
const ACHIEVEMENT_TYPES = [ export const ACHIEVEMENT_TYPES = [
'notes1', 'notes1',
'notes10', 'notes10',
'notes100', 'notes100',

View file

@ -45,7 +45,7 @@ export default class Logger {
} }
const time = dateFormat(new Date(), 'HH:mm:ss'); const time = dateFormat(new Date(), 'HH:mm:ss');
const worker = cluster.isPrimary ? '*' : cluster.worker.id; const worker = cluster.isPrimary ? '*' : cluster.worker!.id;
const l = const l =
level === 'error' ? important ? chalk.bgRed.white('ERR ') : chalk.red('ERR ') : level === 'error' ? important ? chalk.bgRed.white('ERR ') : chalk.red('ERR ') :
level === 'warning' ? chalk.yellow('WARN') : level === 'warning' ? chalk.yellow('WARN') :

View file

@ -11,10 +11,9 @@ export class I18n<T extends Record<string, any>> {
// string にしているのは、ドット区切りでのパス指定を許可するため // string にしているのは、ドット区切りでのパス指定を許可するため
// なるべくこのメソッド使うよりもlocale直接参照の方がvueのキャッシュ効いてパフォーマンスが良いかも // なるべくこのメソッド使うよりもlocale直接参照の方がvueのキャッシュ効いてパフォーマンスが良いかも
@bindThis
public t(key: string, args?: Record<string, any>): string { public t(key: string, args?: Record<string, any>): string {
try { try {
let str = key.split('.').reduce((o, i) => o[i], this.locale) as string; let str = key.split('.').reduce((o, i) => o[i], this.locale as any) as string;
if (args) { if (args) {
for (const [k, v] of Object.entries(args)) { for (const [k, v] of Object.entries(args)) {

View file

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { AchievementService } from '@/core/AchievementService.js'; import { AchievementService, ACHIEVEMENT_TYPES } from '@/core/AchievementService.js';
export const meta = { export const meta = {
requireCredential: true, requireCredential: true,
@ -10,7 +10,7 @@ export const meta = {
export const paramDef = { export const paramDef = {
type: 'object', type: 'object',
properties: { properties: {
name: { type: 'string' }, name: { type: 'string', enum: ACHIEVEMENT_TYPES },
}, },
required: ['name'], required: ['name'],
} as const; } as const;