I don't seam to be able to find an answer for something fairly simple regarding the spread operator on function parameters.
Assume an interface
interface Options {
f1?: number;
f2?: string;
f3?: Object;
}
and function:
private handleAllOptions(...opts: Options[]) {
if(opts && opts.length > 0) { // opts.length returns 1 even if no params are provided
// ... handle options here
}
}
Wheteher I call the function like this:
this.handleAllOptions();
or like this:
this.handleAllOptions(myOptions);
opts.length returns 1 even if no params are provided.
Can you please explain and provide a good way how to check if any params are actually in the spread?