title: Array.reduce gives wrong result type
body: <p>I found a very surprising behavior of Typescript's type-inference and suspect if it is a bug.</p>
  <p>Suppose I have a list of <code>MyItem</code> interface.</p>
  <pre><code>interface MyItem {
      id?: string;
      value: string;
  }
  const myItemList: MyItem[] = [];
  
  </code></pre>
  <p>Please notice that the <code>MyItem.id</code> is optional while <code>MyItem.value</code> is mandatory.</p>
  <p>I want to use method <code>Array.reduce</code> on <code>myList</code>, like this</p>
  <pre><code>const myMap = myItemList.reduce((accum, item) =&gt; ({ ...accum, [item.id!]: item }), {});
  </code></pre>
  <p>This will make the result variable <code>myMap</code> to be of type <code>{}</code>, which is as expected because I supplies <code>{}</code> as the initial value in <code>myItemList.reduce(...)</code>, as shown in the picture below.</p>
  <p><a href="https://i.stack.imgur.com/aTwxY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aTwxY.png" alt="enter image description here" /></a></p>
  <p>Now, the problem occurs when I modify the <code>MyItem</code> interface so that the <code>value</code> becomes optional.</p>
  <pre><code>interface MyItem {
      id?: string;
      value?: string; // &lt;&lt; here I make it optional
  }
  const myItemList: MyItem[] = [];
  
  </code></pre>
  <p>Surprisingly, the exact same <code>myItemList.reduce(...)</code> statement yields a result of <code>MyItem</code> instead of <code>{}</code>.</p>
  <p>Is this a bug? If not, please help me understand what is the reason behind it.</p>
  <p><a href="https://i.stack.imgur.com/Im14K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Im14K.png" alt="enter image description here" /></a></p>