You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However when I access the log property from the request it doesn't point to the right type of the logger being used (Logger<"newLevel">), instead it points to Logger<never> (from the base pino.d.ts AFAIK).
This causes TypeScript to complain when called the method req.log.newLevel(...) inside a controller.
app.get('/test',(req,res)=>{req.log.trace('trace log')// TypeScript doesn't complain!req.log.newLevel('newLevel log')// \__ Property 'newLevel' does not exist on type 'Logger<never>'.ts(2339)res.status(200)})
Question
How could I point TypeScript to look at the correct type of the logger inside the controllers when using custom levels?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
svex99
changed the title
req.log type doesn't resolve the correct type of the logger
TypeScript doesn't resolve the correct type of the logger inside controller (req.log)
Aug 15, 2024
Problem
I have a logger with a custom level that is used as base to create the logger passed to Express.
However when I access the
log
property from the request it doesn't point to the right type of the logger being used (Logger<"newLevel">
), instead it points toLogger<never>
(from the basepino.d.ts
AFAIK).This causes TypeScript to complain when called the method
req.log.newLevel(...)
inside a controller.Question
How could I point TypeScript to look at the correct type of the logger inside the controllers when using custom levels?
Thanks in advance!
The text was updated successfully, but these errors were encountered: