I'm using a package written in TS in a JS app. I have a method with multiple overloads:
overloadedMethod(stringParameter: string): void;
overloadedMethod(stringParameter: string, otherParameter: any): void;
And I call it like this:
if (!myOtherParameter) {
overloadedMethod(myStringParameter)
} else {
overloadedMethod(myStringParameter, myOtherParameter)
}
I do not like this one bit. Have I approached the problem incorrectly, or is there some way I can include the otherParameter only if it is not undefined or null?