There is a function in my code that takes a single parameter of type any
:
function doSomething(param: any) {
// Code to handle the param
}
When I call this function without passing any arguments:
doSomething();
An error is thrown saying: "Expected 1 argument, but received 0." To resolve this error, I have to pass undefined
as the parameter:
doSomething(undefined);
Even though parameters default to undefined
when not explicitly passed, for some reason passing undefined
is necessary in this case. Unfortunately, since the function is part of a library, I cannot mark the parameter as optional.