pino icon indicating copy to clipboard operation
pino copied to clipboard

Type for mixinFn doesn't match docs - mixin doesn't actually get `logger` parameter

Open jason-curtis opened this issue 2 years ago • 3 comments

The docs for the mixin option state that it has 3 arguments: https://getpino.io/#/docs/api?id=mixin-function The first parameter is the value mergeObject or an empty object. The second parameter is the log level number. The third parameter is the logger or child logger itself

However, the type declaration only has two arguments: https://github.com/pinojs/pino/blob/91a3505cfaef323f565e3cfe93f5d5077320faff/pino.d.ts#L31

Which of these versions of reality is correct?

Here's a screenshot of the resultant type error in VS code: image

Pino version: 8.15.0

jason-curtis avatar Aug 17 '23 16:08 jason-curtis

I think the test are the best form of documentation:

https://github.com/pinojs/pino/blob/309cdfbff7ccf4d97b6969b95daec7b6ff9455cf/test/mixin.test.js#L164-L178

Could you check the behavior and make sure docs and types are correct?

mcollina avatar Oct 05 '23 09:10 mcollina

Just as a heads up, my team has worked around this issue for now and I don't expect to have time to check and update the docs.

jason-curtis avatar Oct 12 '23 00:10 jason-curtis

I encountered the same problem.

Type '(obj: any, num: any, logger: any) => { tags: any; }' is not assignable to type 'MixinFn'.
  Target signature provides too few arguments. Expected 3 or more, but got 2.

andreiwow2 avatar Oct 17 '23 10:10 andreiwow2

When can we expect this fix to be released? What would be the best workaround for now?

Downster avatar May 20 '24 22:05 Downster

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.

github-actions[bot] avatar Jun 20 '24 00:06 github-actions[bot]