1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -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[]; boolean?: boolean | string | string[];
alias?: { [key: string]: string | string[] }; alias?: { [key: string]: string | string[] };
string?: string | string[]; string?: string | string[];
default?: { [key: string]: unknown }; // eslint-disable-line @typescript-eslint/no-explicit-any default?: { [key: string]: unknown };
"--"?: boolean; "--"?: boolean;
stopEarly?: boolean; stopEarly?: boolean;
} }

View file

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

View file

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