Function declarations
Destructuring also works in function declarations. For simple cases this is straightforward:
type C = {a: string, b?: number}
function f({a, b}: C): void {
// ...
}
But specifying defaults is more common for parameters, and getting defaults right with destructuring can be tricky. First of all, you need to remember to put the type before the default value.
function f({a, b} = {a: "", b: 0}): void {
// ...
}
f(); // ok, default to {a: "", b: 0}
Then, you need to rememb