pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

pretty() options required in types #326

Closed daniel-j-h closed 2 years ago

daniel-j-h commented 2 years ago

Hey folks, I'm following the readme example

const pino = require('pino')
const pretty = require('pino-pretty')
const logger = pino(pretty())

but I'm hitting the following type-check issue

src/index.ts:14:14 - error TS2554: Expected 1 arguments, but got 0.

14 app.use(pino(pretty()));
                ~~~~~~~~

  node_modules/pino-pretty/index.d.ts:16:29
    16 declare function PinoPretty(options: PrettyOptions_): PinoPretty.PrettyStream;
                                   ~~~~~~~~~~~~~~~~~~~~~~~
    An argument for 'options' was not provided.

Found 1 error in src/index.ts:14

which looks like from here where the options are required

https://github.com/pinojs/pino-pretty/blob/077216cb7287ff9f52980de8c61c44085a7112b5/index.d.ts#L16

I think the options argument should be optionally typed, otherwise typescript complains. Am I missing something, or is this an oversight?

As a workaround for now, this works

app.use(pino(pretty({})));
mcollina commented 2 years ago

Would you like to send a Pull Request to address this issue? Remember to add unit tests.