Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e166b38

Browse files
author
Michal Vlasák
committed
🏷 Fix logFn type in express mdw
It is needed due to TS error: microsoft/TypeScript#33815
1 parent 7c3b817 commit e166b38

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/express.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const expressOnFinished = (logger: Cosmas, req: AckeeRequest) => (_err: Error |
4646

4747
const logFunction = error || serverError ? logger.error : res.out ? logger.info : logger.debug;
4848
const output = error ? errorOutput : standardOutput;
49-
50-
logFunction.call(logger, output.data, output.message);
49+
const logFunctionTyped = logFunction as <T extends object>(obj: T, msg?: string, ...args: any[]) => void;
50+
logFunctionTyped.call(logger, output.data, output.message);
5151
};
5252

5353
const expressMiddleware: RequestHandler = function (

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export interface Cosmas extends PinoLogger {
2929

3030
export interface LogFnSentry {
3131
(msg: string, sentryCallback?: (scope: Scope) => void, ...args: any[]): void;
32-
(obj: object, sentryCallback?: (scope: Scope) => void, ...args: any[]): void;
33-
(obj: object, msg?: string, sentryCallback?: (scope: Scope) => void, ...args: any[]): void;
32+
<T extends object>(obj: T, sentryCallback?: (scope: Scope) => void, ...args: any[]): void;
33+
<T extends object>(obj: T, msg?: string, sentryCallback?: (scope: Scope) => void, ...args: any[]): void;
3434
}
3535

3636
export interface CosmasSentry extends Cosmas {

0 commit comments

Comments
 (0)