title: Typescript Reduce returning wrong Type
body: <p>I'm trying to use reduce to sum my SQL response in two categories, <strong>income</strong> and <strong>outcome</strong>, but I'm getting the "currentValue" (transaction) type as my return instead of the accumulator (BalanceDTO), I'm returning only the accumulator, how I'm getting the transaction type as my return type?    </p>
  
  <p>I really don't know what I'm doing wrong, I am completely stuck for the last two hours.</p>
  
  <pre><code>import { getRepository } from 'typeorm';
  
  import Transaction from '../models/Transaction';
  
  interface BalanceDTO {
    income: number;
    outcome: number;
  }
  
  class GetBalanceService {
    public async execute(): Promise&lt;BalanceDTO&gt; {
      const transactionRepository = getRepository(Transaction);
  
      const transactions = await transactionRepository.find();
  
      const balance = transactions.reduce(
        (accumulator: BalanceDTO, transaction): BalanceDTO =&gt; {
          accumulator[transaction.type] += transaction.value;
          return accumulator; //// HERE -- How it is returning the transactions type? ////
        },
      );
  
      return balance;
    }
  }
  
  export default GetBalanceService;
  </code></pre>