Closed
Description
function foo({ x, y = {}} = { x: 0, y: {}}) {
}
foo(); // Fine
foo({ x: 0, y: 0 }); // Fine
foo({ x: 0 }); // Error
The last line should not be an error because the y property has a default initializer. The error goes away if I remove the default initializer { x: 0, y: {}}
on the parent.
I think the rule would be that even if we get the type of a parameter / variable / binding element from an initializer, we still have to traverse the binding pattern to determine whether binding properties are optional.