Why is in case "ERROR" the variable "error" not strictly typed as "Error" and still either "string" or "Error"?
type Levels = {
ERROR: [error: Error];
WARNING: [message: string];
INFO: [message: string];
};
public log<K extends keyof Levels>(level: K, ...args: Levels[K]): void {
const date = new Date();
let message: string | null = null;
switch (level) {
case "ERROR": {
const error = args[0];
message = `[${Moment(date).format("YYYY-MM-DD HH:mm:ss")}] [${level}] - ${error.message}\n\n`;
}
}
}