From c991fd5e4f8e6b807f9e397e774a592a388284b8 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Sun, 30 Aug 2020 20:31:42 +0800 Subject: [PATCH] typings: adjust typings --- packages/koishi-core/src/app.ts | 4 ++-- packages/koishi-utils/src/logger.ts | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/koishi-core/src/app.ts b/packages/koishi-core/src/app.ts index 1cb51f8404..af7300ed38 100644 --- a/packages/koishi-core/src/app.ts +++ b/packages/koishi-core/src/app.ts @@ -46,8 +46,8 @@ export class App extends Context { _commands: Command[] _commandMap: Record _hooks: Record any][]> - _userCache: LruCache>> - _groupCache: LruCache>> + _userCache: LruCache, Promise>> + _groupCache: LruCache, Promise>> private _nameRE: RegExp private _prefixRE: RegExp diff --git a/packages/koishi-utils/src/logger.ts b/packages/koishi-utils/src/logger.ts index 2b270eb811..90563b2d27 100644 --- a/packages/koishi-utils/src/logger.ts +++ b/packages/koishi-utils/src/logger.ts @@ -14,6 +14,10 @@ const instances: Record = {} type LogFunction = (format: any, ...param: any[]) => void +type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug' + +export interface Logger extends Record {} + export class Logger { static readonly SUCCESS = 1 static readonly ERROR = 1 @@ -44,12 +48,6 @@ export class Logger { private code: number private displayName: string - public success: LogFunction - public error: LogFunction - public info: LogFunction - public warn: LogFunction - public debug: LogFunction - constructor(private name: string, private showDiff = false) { if (name in instances) return instances[name] let hash = 0 @@ -71,7 +69,7 @@ export class Logger { return Logger.color(this.code, value, decoration) } - private createMethod(name: string, prefix: string, minLevel: number) { + private createMethod(name: LogType, prefix: string, minLevel: number) { this[name] = (...args: [any, ...any[]]) => { if (this.level < minLevel) return process.stderr.write(prefix + this.displayName + this.format(...args) + '\n')