🚀 Feature: Overloading consoleLog in reporters.Base for custom reporter #4971
Open
Description
opened on Mar 9, 2023
When creating custom reporter, and to utilize reporters.Base functions, it is best to extends reporter.Base function.
However, mocha doesn't provide type-safe (for typescript) way to overload consoleLog function, since many of reporter.Base functions are directly call Base.consoleLog function. it would be better to overload it if we don't want it print them to console
I found I can force overload it through
(Mocha.reporters.Base as any).consoleLog = (...data: any[]) => {
// do my own logging
}
However, I feel this is undocumented and unexposed to @types/mocha, so it is subjected to change and breaks code above
can we have declared way to overload that method, ideally like
class MyReporter extends Mocha.reporters.base {
override consoleLog(... data) {
// my own logging
}
}
Activity