Currently working on resolving an odd scenario with a logger. Essentially, calls like log({ info: 'information' })
function as expected, but log(new Error())
falls short.
While no solution is readily available, the goal is to override the log method to accept all objects except errors as parameters. Is this achievable in Typescript?
An attempt was made using conditional types:
type NotError<T> = T extends Error ? never : T;
log(NotError<object>): void
Despite this approach, calling log(new Error())
still does not produce any errors or warnings.
Side note: The issue stems from all objects having non-enumerable properties, although our only encountered scenario involving such objects are Errors.