Skip to content

Typescript: logLevel type definition in RouteShorthandOptions does not include 'silent' option #4430

@grreeenn

Description

@grreeenn

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.9.2

Plugin version

No response

Node.js version

16.15.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

12.6

Description

Pino documentation states that in order to turn off the logging for a certain route, one should set `{logLevel: 'silent'} in the route options.

This works well, however it doesn't play nice with Typescript. It happens because logLevel property in RouteShorthandOptions interface uses an alias for pino.Level, instead of pino.LevelWithSilent as its type -

export type LogLevel = pino.Level

Steps to Reproduce

fastify.get('/your-route', { logLevel: 'silent' }, (request, reply) => {
  reply.send({ hello: 'world' })
})

will give you TS2322: Type '"silent"' is not assignable to type 'Level | undefined'.

Expected Behavior

no TS error should occur

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions