strictNullChecks (#4666)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo
2019-04-13 01:43:22 +09:00
committed by GitHub
parent 4ee40c3345
commit 987168b863
214 changed files with 939 additions and 785 deletions

View File

@@ -9,14 +9,14 @@ import { genId } from '../misc/gen-id';
type Domain = {
name: string;
color: string;
color?: string;
};
type Level = 'error' | 'success' | 'warning' | 'debug' | 'info';
export default class Logger {
private domain: Domain;
private parentLogger: Logger;
private parentLogger: Logger | null = null;
private store: boolean;
constructor(domain: string, color?: string, store = true) {
@@ -33,7 +33,7 @@ export default class Logger {
return logger;
}
private log(level: Level, message: string, data: Record<string, any>, important = false, subDomains: Domain[] = [], store = true): void {
private log(level: Level, message: string, data?: Record<string, any> | null, important = false, subDomains: Domain[] = [], store = true): void {
if (program.quiet) return;
if (!this.store) store = false;
@@ -80,7 +80,7 @@ export default class Logger {
}
}
public error(x: string | Error, data?: Record<string, any>, important = false): void { // 実行を継続できない状況で使う
public error(x: string | Error, data?: Record<string, any> | null, important = false): void { // 実行を継続できない状況で使う
if (x instanceof Error) {
data = data || {};
data.e = x;
@@ -90,21 +90,21 @@ export default class Logger {
}
}
public warn(message: string, data?: Record<string, any>, important = false): void { // 実行を継続できるが改善すべき状況で使う
public warn(message: string, data?: Record<string, any> | null, important = false): void { // 実行を継続できるが改善すべき状況で使う
this.log('warning', message, data, important);
}
public succ(message: string, data?: Record<string, any>, important = false): void { // 何かに成功した状況で使う
public succ(message: string, data?: Record<string, any> | null, important = false): void { // 何かに成功した状況で使う
this.log('success', message, data, important);
}
public debug(message: string, data?: Record<string, any>, important = false): void { // デバッグ用に使う(開発者に必要だが利用者に不要な情報)
public debug(message: string, data?: Record<string, any> | null, important = false): void { // デバッグ用に使う(開発者に必要だが利用者に不要な情報)
if (process.env.NODE_ENV != 'production' || program.verbose) {
this.log('debug', message, data, important);
}
}
public info(message: string, data?: Record<string, any>, important = false): void { // それ以外
public info(message: string, data?: Record<string, any> | null, important = false): void { // それ以外
this.log('info', message, data, important);
}
}