pinojs/pino

Typescript/Intellisense not accurate after using logMethod hook

Closed this issue · 3 comments

Hi,

I used this logMethod hook to change the function signature for the logger functions.

However, typescript expects the default pino function signature.

image

Do you have any advice on how to fix this? (Using the new log method, the default pino function signature would not work and typescript/intellisense should reflect this)

Thanks!

I have no clue on how to fix this is in TS. Likely you'd have to define your own types.

@mcollina yep, that was it. Thanks.

for any others who may want to do this in the future, we did it like this:

type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'

type ServerlessLogger = Omit<Logger, LogLevel> & {
  [K in LogLevel]: CustomLogFn
}

where CustomLogFn was a modified version of

pino/pino.d.ts

Line 315 in af002c7

interface LogFn {

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.