Closed atheck closed 2 years ago
Creating a standard type for the whole logger class without knowing the log level names first is complex. However if you want to have a better typed log function you could create your own type and assign it to the logger object:
type myLoggerType = {
debug: (...args: unknown[]) => void;
info: (...args: unknown[]) => void;
warn: (...args: unknown[]) => void;
error: (...args: unknown[]) => void;
};
const LOG = logger.createLogger(loggerConfig) as any as myLoggerType;
Thanks for your reply @alessandro-bottamedi. This is a good solution.
Is it possible to not use
any
for dynamic log methods in classlogTyped
? Maybe these methods can be typed like this:(...args: unknown []) => void