title: Type '{}' is not assignable to type 'object[]' during map and reduce in typescript
body: <p>I have a list of file names in an array. My goal is to read all the files in the array and convert them to json from string.<br>
  This is the signature of the readAFile() API.  </p>
  
  <pre><code>readAFile(fileName: string, encoding: 'utf-8'): any {
    return fs.readFileSync(filename, {encoding: encoding});
  }
  </code></pre>
  
  <p>Now, I have an array containing absolute path to all the files that is to be read <code>files = ['/path/to/file1', '/path/to/file2', '/path/to/file3']</code>.<br>
  I have another function that maps each file name in this list to the <code>readAFile()</code> and reads them and converts them to JSON like this:  </p>
  
  <pre><code>readAllFiles(files: string[]): object[] {
    **return** files.map((aFile) =&gt; {
      return readAFile(aFile); // this api's return type is 'any'
    })
    .reduce((listOfJson, dataOfOneFile) =&gt; {
       const jsonData = JSON.parse(dataOfOneFile);
       listOfJson.push(jsonData);
       return listOfJson;
    }, []);
  }
  </code></pre>
  
  <p>I want to include the file name as well, here's what i added  </p>
  
  <pre><code>  files.map((aFile) =&gt; {
      const mappedData = {};  // Added this
      mappedData['data'] = readAFile(aFile); // the data now goes into this object
      mappedData['inputFile'] = aFile;
      return mappedData;    &lt;------ ERROR: Type '{}' is not assignable to type 'object[]'.
    })
  </code></pre>
  
  <p>I figured that the simple fix to this problem is <code>return [mappedData];</code>. I am not sure i understand this correctly. Could some one help me understand why is this an error? Also, any alternative suggestions are welcome.<br>
  EDIT 1: added missing return statement in readAllFiles(). typo.</p>