I have this piece of code:
const format = winston.format;
format: format.combine(
format.colorize({ level: true, message: false }),
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
)
but when I compile the project I got this error:
error TS7006: Parameter 'info' implicitly has an 'any' type.
with the solution proposed I got this error:
src/common/logging/logging.service.ts:95:43 - error TS1005: ',' expected.
95 format.printf(info:any => `${info.timestamp} ${info.level}: ${info.message}`)
This is a Typescript error. It expects you to define a type for the 'info' argument. You can replace info
with info:any
for the fix.
Just need a brackets
format.printf((info:any) => `${info.timestamp} ${info.level}: ${info.message}`)
The problem can be resolved as @BerkOzturk suggested by providing:any type. By default the typescript compiler expects that you will provide type for every variable.
The other solution for this issue is to say compiler to stop doing that by setting noImplicitAny to false in tsconfig.json file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.