title: How to use assertion in destructuring syntax?
body: <p>In Typescript, how can I use assertion in destructuring?</p>
  
  <pre><code>type StringOrNumber = string | number
  
  const obj = {
    foo: 123 as StringOrNumber
  }
  
  const { foo } = obj
  </code></pre>
  
  <p>I didn't find a convenient way to add <code>number</code> type assertion on const <code>foo</code>. Two workarounds are:</p>
  
  <pre><code>// A:
  const { foo } = obj as { foo: number }
  
  // B:
  const { foo: foo2 } = obj
  
  const foo = &lt;number&gt;foo2
  </code></pre>
  
  <p>The first is a burden to rewrite the <code>obj</code>'s type when its type is nested and complicated. The second seems weird. I'm assuming such a syntax like:</p>
  
  <pre><code>const { &lt;number&gt;foo } = obj
  </code></pre>
  
  <p>can absolutely help us asserting the type from nested and complicated destructuring.</p>