This is a valid mistake. You cannot have multiple method implementations; they need to be part of the same body. While you can have different method signatures for your overloads, the actual implementation must support all of them. For example:
public from(arg: Expression<any>): T;
public from(...args: Expression<any>[]): T {
// The method needs to be implemented here to satisfy both signatures
return this.self;
}
In this case, it seems like you only really need one signature since the other is essentially a subset of the first. So, you could simplify it to just:
public from(...args: Expression<any>[]): T {
// Implement this method to support both signatures
return this.self;
}
It's important to understand that even though you can define the function signature through overloads, they must ultimately share the same implementation.
EDIT:
Based on your updated comment and post, here is how it should look. Remember, you need to ensure that you distinguish which overload you are using in the implementation:
public groupBy(e: Expression<any>): T;
public groupBy(...o: Expression<any>[]): T {
if (o.length === 1) {
// Implementation for the first overload with a single argument
const e = o[0];
e = this.convert(e, Role.GROUP_BY);
this.metadata.addGroupBy(e);
} else {
// Implementation for the second overload with either no arguments or more than 2 arguments
for (const e of o) {
// Recursive call to handle each argument
this.groupBy(e);
}
}
return this.self;
}