question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type incompatibility after upgrading pino to 8.6.0

See original GitHub issue

Upgraded pino to latest release, 8.6.0 in a project using Next.js, pino, and pino-http.

A test that assigns the log field on a NextApiRequest as part of its setup now fails with the following error:

Type 'Logger<LoggerOptions | DestinationStream>' is not assignable to type 'LoggerExtras<LoggerOptions>'

I tried to use a mock instead and still encountered the error.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Nulifiercommented, Nov 1, 2022

I’m on the latest version of typescript (4.8.4) and I’m still experiencing the same issue. I’m trying to pass an existing pino logger instance to pino-http and I get the same error. Here is a simple example:

import pino from "pino";
import pinoHttp from "pino-http";

const log = pino();

const httpLogger = pinoHttp({ logger: log });
const httpLogger2 = pinoHttp({ logger: log.child({ m: "test" }) });

Casting the logger to any and then passing it to the logger option works as a temporary workaround.

1reaction
manvydasucommented, Oct 13, 2022

Hey @mcollina

I’ve noticed the similar behavior after upgrading to latest pino and pino-http, not sure if the usage is incorrect, but after upgrading such code no longer works. (pino.Logger and resulting type from req.log.child can not casted to same type)

      let childLogger: pino.Logger | null = null;

      childLogger = req.log.child({ test: 'test' });

And then the error looks like this:

TS2322: Type 'Logger<LoggerOptions & ChildLoggerOptions>' is not assignable to type 'Logger<LoggerOptions> | null'.   Type 'Logger<LoggerOptions & ChildLoggerOptions>' is not assignable to type 'Logger<LoggerOptions>'.     Property 'onChild' is missing in type 'BaseLogger & LoggerExtras<LoggerOptions & ChildLoggerOptions> & Record<never, LogFn>' but required in type 'LoggerExtras<LoggerOptions>'.

Previously it was possible to use pino.Logger and child logger from req.log.child as a same type. Maybe it’s an issue of pino though.

Is this example enough?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · pinojs/pino-http - GitHub
Type incompatibility after upgrading pino to 8.6.0. #247 opened on Sep 20 by thomas-yaa · 5 · Incorrect types for exported stdSerializers bug...
Read more >
Blood Type Incompatibility, Rh Incompatibility, and Jaundice
It occurs when the mother is type O and the baby is A, B, or AB. As with Rh incompatibility, this means that...
Read more >
Rh incompatibility: MedlinePlus Medical Encyclopedia
Rh incompatibility is a condition that develops when a pregnant woman has Rh-negative blood and the baby in her womb has Rh-positive blood....
Read more >
Rh Incompatibility: Symptoms, Diagnosis & Treatments
If an incompatibility exist, it can be treated. ... A positive or negative symbol after your blood type indicates your Rh factor. For...
Read more >
Rh Incompatibility During Pregnancy (for Parents) - Kids Health
This basic test determines your blood type and Rh factor, which may play an ... When a mother-to-be and father-to-be are not both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found