1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 17:49:08 -05:00

use unknown instead of any (denoland/deno_std#486)

Original: c64734cbd9
This commit is contained in:
Xin Du (Clark) 2019-06-06 17:56:33 +01:00 committed by Ryan Dahl
parent 8e8f936e40
commit 2e0ab295a3
4 changed files with 16 additions and 28 deletions

View file

@ -4,7 +4,7 @@ export interface ArgParsingOptions {
boolean?: boolean | string | string[];
alias?: { [key: string]: string | string[] };
string?: string | string[];
default?: { [key: string]: unknown }; // eslint-disable-line @typescript-eslint/no-explicit-any
default?: { [key: string]: unknown };
"--"?: boolean;
stopEarly?: boolean;
}

View file

@ -4,8 +4,7 @@ import { BaseHandler } from "./handlers.ts";
export interface LogRecord {
msg: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: any[];
args: unknown[];
datetime: Date;
level: number;
levelName: string;
@ -24,8 +23,7 @@ export class Logger {
this.handlers = handlers || [];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_log(level: number, msg: string, ...args: any[]): void {
_log(level: number, msg: string, ...args: unknown[]): void {
if (this.level > level) return;
// TODO: it'd be a good idea to make it immutable, so
@ -38,7 +36,6 @@ export class Logger {
level: level,
levelName: getLevelName(level)
};
this.handlers.forEach(
(handler): void => {
handler.handle(record);
@ -46,28 +43,23 @@ export class Logger {
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
debug(msg: string, ...args: any[]): void {
debug(msg: string, ...args: unknown[]): void {
this._log(LogLevel.DEBUG, msg, ...args);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info(msg: string, ...args: any[]): void {
info(msg: string, ...args: unknown[]): void {
this._log(LogLevel.INFO, msg, ...args);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
warning(msg: string, ...args: any[]): void {
warning(msg: string, ...args: unknown[]): void {
this._log(LogLevel.WARNING, msg, ...args);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error(msg: string, ...args: any[]): void {
error(msg: string, ...args: unknown[]): void {
this._log(LogLevel.ERROR, msg, ...args);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
critical(msg: string, ...args: any[]): void {
critical(msg: string, ...args: unknown[]): void {
this._log(LogLevel.CRITICAL, msg, ...args);
}
}

View file

@ -62,20 +62,15 @@ export function getLogger(name?: string): Logger {
return state.loggers.get(name)!;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const debug = (msg: string, ...args: any[]): void =>
export const debug = (msg: string, ...args: unknown[]): void =>
getLogger("default").debug(msg, ...args);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const info = (msg: string, ...args: any[]): void =>
export const info = (msg: string, ...args: unknown[]): void =>
getLogger("default").info(msg, ...args);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const warning = (msg: string, ...args: any[]): void =>
export const warning = (msg: string, ...args: unknown[]): void =>
getLogger("default").warning(msg, ...args);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const error = (msg: string, ...args: any[]): void =>
export const error = (msg: string, ...args: unknown[]): void =>
getLogger("default").error(msg, ...args);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const critical = (msg: string, ...args: any[]): void =>
export const critical = (msg: string, ...args: unknown[]): void =>
getLogger("default").critical(msg, ...args);
export async function setup(config: LogConfig): Promise<void> {

View file

@ -16,8 +16,9 @@ class TestHandler extends log.handlers.BaseHandler {
}
test(async function defaultHandlers(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const loggers: { [key: string]: (msg: string, ...args: any[]) => void } = {
const loggers: {
[key: string]: (msg: string, ...args: unknown[]) => void;
} = {
DEBUG: log.debug,
INFO: log.info,
WARNING: log.warning,