Skip to content

Commit

Permalink
feat: more type annotations (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Nov 3, 2022
1 parent 87cdbac commit d023800
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ interface Options {
silent?: boolean
}

// @ts-ignore
type writeLogF = (...args: any[]) => void;
type ConsoleArgs = [object | string, ...string[]];

type writeLogF = (...args: ConsoleArgs) => void;

class Logger {

Expand Down Expand Up @@ -69,7 +70,7 @@ class Logger {
}
}

_writeLogOutput(level, consoleArgs) {
_writeLogOutput(level: number, consoleArgs: ConsoleArgs) {
let errArg;
if (typeof consoleArgs[0] === 'object') {
errArg = consoleArgs.shift();
Expand Down Expand Up @@ -123,27 +124,27 @@ class Logger {
}
}

trace(...args) {
trace(...args: ConsoleArgs) {
this._writeLogOutput(TRACE, args);
}

debug(...args) {
debug(...args: ConsoleArgs) {
this._writeLogOutput(DEBUG, args);
}

info(...args) {
info(...args: ConsoleArgs) {
this._writeLogOutput(INFO, args);
}

warn(...args) {
warn(...args: ConsoleArgs) {
this._writeLogOutput(WARN, args);
}

error(...args) {
error(...args: ConsoleArgs) {
this._writeLogOutput(ERROR, args);
}

fatal(...args) {
fatal(...args: ConsoleArgs) {
this._writeLogOutput(FATAL, args);
}
}
Expand Down

0 comments on commit d023800

Please sign in to comment.