winstonjs/logform

[Feature Request]: Add generic type support for `format` function

SamuelTrew opened this issue · 0 comments

The vision

Currently when using the format function, the opts are typed as any which I think is unneeded.

It could instead be like:

export type TransformFunction<T> = (info: TransformableInfo, opts?: T) => TransformableInfo | boolean;

export function format<T>(transform: TransformFunction<T>): FormatWrap;

So as to keep full type support

Use case

interface Info {
   x?: string
   y: number
}

const doSmth = format<Info>((info, opts) => {
   if (opts.x)
      info.timestamp = x
   return info
})

Additional information

No response

🔎 Search Terms

type, types