title: Can you have optional destructured arguments in a Typescript function?
body: <p>I'd like to write a function that takes an object argument, uses destructuring in the function signature, and have that argument be optional:</p>
  
  <pre><code>myFunction({opt1, opt2}?: {opt1?: boolean, opt2?: boolean})
  </code></pre>
  
  <p>However, Typescript doesn't let me ("A binding pattern parameter cannot be optional in an implementation signature.").</p>
  
  <p>Of course I could do it if I didn't destructure:</p>
  
  <pre><code>myFunction(options?: {opt1?: boolean, opt2?: boolean}) {
    const opt1 = options.opt1;
    const opt2 = options.opt1;
    ...
  </code></pre>
  
  <p>It seems like these should be the same thing, yet the top example is not allowed.</p>
  
  <p>I'd like to use a destructured syntax (1) because it exists, and is a nice syntax, and it seems natural that the two functions above should act the same, and (2) because I also want a concise way to specify defaults:</p>
  
  <pre><code>myFunction({opt1, opt2 = true}?: {opt1?: boolean, opt2?: boolean})
  </code></pre>
  
  <p>Without destructuring, I have to bury these defaults in the implementation of the function, or have an argument that is actually some class with a constructor...</p>