I have a class definition as follows:
class Test {
a(msg: string): string;
a(msg: string, ...args: unknown[]): string | { msg: string, args: unknown[]} {
if (args) {
return { msg: msg, args: args };
}
return msg;
}
}
However, I get compilation errors if I do this:
new Test().a("test", "a", 1, 2, 3);
"Expected 1 arguments, but got 5"
How can I properly overload this method to provide different return types for the different signatures?