In Java, we can do something like :
void myFunction(int... ints) {
// ints will be int[], that will never be null
}
// both call method will works :
myFunction();
myFunction(0, 1, 5);
But, in angular:
myFunction(obj?: MyObj[]) {
// obj will be an array that can be null
// obj will by typed as "MyObj[] | undefined"
}
myFunction(); // this works
myFunction(obj1, obj2); // error
But the "obj" variable can be null. Without the ?
it's not possible to run the first function.
How can I do to have an argument with unknown amount of item, but never null?