title: typescript fix error argument of type is not assignable
body: <p>I don't know why I'm facing a problem. I have a function that takes an array of objects. Every object has a property named <code>id</code> and I wanted to get the last <code>id</code> from the given data. The code is working fine.</p>
  
  <pre><code>type Data = object;
  
  const data = [
      {
          'id': 1,
          'name': 'Uncategorized',
      },
      {
          'id': 2,
          'name': 'DSLR Cameras',
      },
      {
          'id': 3,
          'name': 'Printer / Ink',
      },
  ];
  
  const getLastId = (data: Data[]): number =&gt; {
      if (Array.isArray(data) &amp;&amp; data.length &gt; 0) {
          // Create an array of Id's of all items
          const idsArray: number[] = [];
          data.forEach((obj: { id: number }) =&gt; idsArray.push(obj.id));
          // Return last element id
          return idsArray[data.length - 1];
      } else {
          return 1;
      }
  };
  </code></pre>
  
  <p>But, at the following line, an error is coming.</p>
  
  <blockquote>
    <p>data.forEach((obj: { id: number }) => idsArray.push(obj.id));</p>
  </blockquote>
  
  <pre><code>TS2345: Argument of type '(obj: { id: number; }) =&gt; number' is not assignable to parameter of type '(value: object, index: number, array: object[]) =&gt; void'.
    Types of parameters 'obj' and 'value' are incompatible.
      Property 'id' is missing in type '{}' but required in type '{ id: number; }'.
  </code></pre>
  
  <p><strong>What type of error it is and How to fix this?</strong>
  <a href="http://www.typescriptlang.org/play/#code/C4TwDgpgBAIghsOUC8UD2AjAVhAxsAbgCgjc0A7AZ2CgBMElUBtIqNqAb1fZ4HIBLWrwBcUAIwAabjza9ycALYQRUXgFVyuBBADmaAE78AXhCFSeAX3PsuM9gKGiATNbtzFy0bxgBlADIASlAAwh76cJS8rlBW0pxxfIIqAMzRfPJKKrwACobkwBD6UAD0UACS5ADWUXGxALrEpBTUUDoQwH4RwGW0KFAAFPSIovCITHUAlKLkAK4KGIUoAHzxPPwAZgMAgvrhIAB0-JQ7e4MME1AAZJd0DPsANhDkOsAAFlArAAwXtnYlpcF9BBtFA4ORQbs4CB0JserxKDDQfd7lB+AUFJQEuwyFQaIJjpCQNM5gt9OM+uNiH9boh9usDABROC4V79fqYLCiDio2jE+aLCwXZArfEnKH7MAzSisjmHWgTCZUv7FUoBdozfTg+5dKAQR5KfI8rFsIHADXg0WEphDOAPJ4vd4AWnEDVquvulGgvzspvN4iVbAsRAsBCAA" rel="nofollow noreferrer">Link</a></p>