`any` type for dynamic log methods
atheck opened this issue · 2 comments
atheck commented
Is it possible to not use any
for dynamic log methods in class logTyped
? Maybe these methods can be typed like this:
(...args: unknown []) => void
alessandro-bottamedi commented
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;
atheck commented
Thanks for your reply @alessandro-bottamedi. This is a good solution.