I am working with a function that has four parameters, where the first parameter is mandatory, the second and third are optional, and the fourth has a default value:
class MyClass {
static myFunc(param1: string, param2? : string, param3? : string, param4:boolean=true)
{
...
}
}
When calling this function, I want to provide a value for the first parameter and override the default boolean value of the fourth parameter. However, simply using
MyClass.myFunc("foo", false)
doesn't work. Should I reconsider the design of the function signature? What is the common practice in TypeScript for handling such scenarios?