I add a custom log-level "silly".
Log with fastify.log.silly('...')
produces a TypeScript error:
Property 'silly' does not exist on type 'FastifyBaseLogger'.ts(2339)
How can this be type-safe extended?
I add a custom log-level "silly".
Log with fastify.log.silly('...')
produces a TypeScript error:
Property 'silly' does not exist on type 'FastifyBaseLogger'.ts(2339)
How can this be type-safe extended?
Copyright © 2021 Jogjafile Inc.
If you are using fastify version >= 4.16.0,
FastifyBaseLogger
is exported as an interface instead of a type alias and you can use declaration merging pattern to extend it:Now the complier "knows" that silly is part of the logger interface and will not produce an error when calling
fastify.log.silly('...')