title: Does typescript not check types on the result of an Array.map?
body: <pre><code>interface Company {
    id: string;
    name: string;
  }
  
  type input = Company;
  
  // This fails as the types don't match
  const ACME: input = { id: '123', name: 'ACME', ceo: 'Eric' };
  
  function mapIds(ids: string[]): input[] {
    // This compiles, but it shouldn't, or is Array.map returning something different?
    return ids.map(id =&gt; ({ id: '1', name: '1', ceo: 'Eric' }));
  
    // This fails as types don't match
    return [{ id: '1', name: '2', ceo: 'Eric' }];
  }
  ￼
  </code></pre>
  
  <p>Given the above code, the typescript compiler will not allow the function to return values that don't belong in the type, however if the return is from an Array.map, it does. You can see this with the above snippet on the Typescript Playground: <a href="https://www.typescriptlang.org/play/" rel="noreferrer">https://www.typescriptlang.org/play/</a></p>
  
  <p>Could anyone explain what's up with that?</p>