title: Type problems with reduce in TypeScript
body: <p>I have a simple reduce function which would work in JS, but obviously TypeScript doesn't want to allow me use that.
  I am supposed to be group clients and find how much they paid for their orders. I wanted to at first make a reduce on orders, so I get an object with <code>idOfClient -&gt; Array of prices</code>.
  Then I wanted to make a reduce on the Array of prices, so I would get the sum of the array, but it seems like TypeScript doesn't know that there is an array as a value of key, it sees <code>idClientsWithPrice</code> as empty Object I guess.
  With my code I get an error:</p>
  <pre><code>Property 'reduce' does not exist on type 'never'.
  </code></pre>
  <p>My code:</p>
  <pre><code>export const summaryOfClient = (state: RootStore) =&gt; {
  
      const idClientsWithPrices = state.orders.orders.reduce((acc,curr) =&gt; {
          if (acc[curr.client as keyof typeof acc]) {
              return {...acc, [curr.client]: [...acc[curr.client as keyof typeof acc], curr.price]}
          }
          return {...acc, [curr.client]: [curr.price]}
  
          // acc[curr.client as keyof typeof acc] ?  {...acc, [curr.client]: [...acc[curr.client as keyof typeof acc],curr]} :
          // {...acc, [curr.client]: [curr]}
      }, {})
      const idClientsWithSum = Object.keys(idClientsWithPrices).map(id =&gt; {
          return {
              id: id,
              sum: idClientsWithPrices[id as keyof typeof idClientsWithPrices].reduce((acc: number,curr: number) =&gt; {
                  acc+curr
              }, 0)}
      })
  }
  </code></pre>
  <p>Is there any way to handle that?
  My second question would be also why the commented code is not equivalent to my <code>if</code> statement? I wanted to do it using tenary operator, but it says that it was not an expression or call</p>