Skip to content

Commit

Permalink
fix(types): make ILogger to be compatible with standard console
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Apr 4, 2019
1 parent 8cb08c1 commit 888a85f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/facade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"devDependencies": {
"@types/jest": "^24.0.9",
"@types/node": "^11.11.3",
"dts-generator": "^3.0.0",
"flowgen": "^1.7.0",
"replace-in-file": "^3.4.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/facade/src/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"lib": ["es6"],
"lib": ["es6", "dom"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
Expand All @@ -31,4 +31,4 @@
"exclude": [
"node_modules"
]
}
}
4 changes: 2 additions & 2 deletions packages/types/src/main/ILogger.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Inherits log4j logging levels contract and Logback values

export type ILoggerMethod = (...args: any[]) => undefined | null
export type ILoggerMethod = (...args: any[]) => void

export type TLogLevel = number

export interface ILogger {
trace: ILoggerMethod,
debug: ILoggerMethod,
info: ILoggerMethod,
log: ILoggerMethod,
log: ILoggerMethod, // Legacy, use .info() instead
warn: ILoggerMethod,
error: ILoggerMethod,
fatal?: ILoggerMethod,
Expand Down
6 changes: 4 additions & 2 deletions packages/types/src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const emitter: IEventEmitter = {
const brokenLogLevel: TLogLevel = 'info'; // $ExpectError
const traceLogLevel: TLogLevel = 5e3;

const brokenLogMethod: ILoggerMethod = () => 'foo'; // $ExpectError
const brokenLogMethod: ILoggerMethod = null; // $ExpectError
const logMethod: ILoggerMethod = () => undefined;

const brokenLogger: ILogger = {
Expand All @@ -71,7 +71,7 @@ const brokenLogger: ILogger = {
info: logMethod,
log: logMethod,
warn: logMethod,
error: () => 'foo' // $ExpectError
error: null // $ExpectError
};

const logger: ILogger = {
Expand All @@ -84,6 +84,8 @@ const logger: ILogger = {
custom: () => 'foo'
};

const legacyLogger: ILogger = console;

// TUtilGet

const brokenUtilGet: TUtilGet = (obj: object, path: any[], defaultValue?: any) => { obj || path || defaultValue; }; // $ExpectError
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"lib": ["es6"],
"lib": ["es6", "dom"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
Expand All @@ -31,4 +31,4 @@
"exclude": [
"node_modules"
]
}
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"skipLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"composite": true
"composite": true,
"strictNullChecks": true
}
}

0 comments on commit 888a85f

Please sign in to comment.