Skip to content

Conversation

@dancastillo
Copy link
Member

Checklist

updates typescript pino type to pick

@github-actions github-actions bot added the typescript TypeScript related label Aug 12, 2025
Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinions, maybe Picking from pino is indeed better for types?

@gurgunday gurgunday requested a review from a team August 12, 2025 09:54
@gurgunday gurgunday merged commit 812ef58 into fastify:main Aug 14, 2025
30 checks passed
@arthurfiorette
Copy link
Contributor

arthurfiorette commented Oct 21, 2025

This has now created another issue where we cannot use a FastifyBaseLogger instance where a pino's BaseLogger instance is expected. Because now FastifyBaseLogger deviated from BaseLogger by not adding the newest get msgPrefix() property. Was it intended to change it this way? Or at least add this breaking change in a non major version?

const app = fastify()

something(app.log)
//            ^
// Argument of type 'FastifyBaseLogger' is not assignable to parameter of type 'BaseLogger'.

function something(logger: BaseLogger) {
  logger.info('Hello, world!')
}

From my understandings, this change comes from #6286 where typescript correctly warned that fastify CI was missing a field to match the new structure of BaseLogger.

Ihmo, this PR should be reverted and #6286 should be merged instead.

cc @jsumners @gurgunday @dancastillo

@Eomm
Copy link
Member

Eomm commented Oct 22, 2025

Fastify uses a generic logger interface that requires a limited set of methods:

This PR fixes this issue: we don't want to mock the pino interface, we want to ship pino included.
For this reason, I would not revert it, but I'm open to the @fastify/typescript decision.

As general fix, I suggest to don't use module's logger in the code

type MyApplicationLogger = FastifyBaseLogger  as BaseLogger

This simplify these kind of changes.

Or at least add this breaking change in a non major version?

ATM we follow the principale like the typescript module does: types may break in minor changes.

@arthurfiorette
Copy link
Contributor

@Eomm BaseLogger doesn't have .child(), thus using BaseLogger won't work in many use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants