Prerequisites
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
Prerequisites
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
logLevelproperty inRouteShorthandOptionsinterface uses an alias forpino.Level, instead ofpino.LevelWithSilentas its type -fastify/types/logger.d.ts
Line 16 in 9c1be2a
Steps to Reproduce
will give you
TS2322: Type '"silent"' is not assignable to type 'Level | undefined'.Expected Behavior
no TS error should occur