Skip to content

fix: allow pino logger instance assignment#6750

Open
puneetdixit200 wants to merge 1 commit into
fastify:mainfrom
puneetdixit200:fix-pino-logger-instance-types
Open

fix: allow pino logger instance assignment#6750
puneetdixit200 wants to merge 1 commit into
fastify:mainfrom
puneetdixit200:fix-pino-logger-instance-types

Conversation

@puneetdixit200
Copy link
Copy Markdown

Fixes #4960.

This updates the childLoggerFactory type surfaces to accept FastifyBaseLogger instead of the concrete logger generic inferred from loggerInstance. That avoids making FastifyInstance<..., pino.Logger> fail assignment to the default FastifyInstance type under strict function types.

The added type test covers assigning a Fastify instance created with loggerInstance: pino() to FastifyInstance.

Verification:

  • Red before fix: npx tsd --files test/types/fastify.test-d.ts failed on the new Pino logger instance assignment.
  • Green after fix: npx tsd --files test/types/fastify.test-d.ts
  • npm run test:types
  • npm run lint
  • git diff --check
  • npm test

@github-actions github-actions Bot added the typescript TypeScript related label Jun 4, 2026
@metcoder95 metcoder95 requested a review from a team June 4, 2026 08:29
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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.

TypeScript issue when passing Pino instance to fastify constructor

3 participants