title: Pass generic type and use type property
body: <p>I'm quite new in TypeScript and despite that I've red docs I simply cannot achieve what I want with generics.</p>
  
  <p>I want to do something like that:</p>
  
  <pre><code>declare interface ObjectInterface {
      someKey: string
  }
  
  const model: SomeInterface = createModel&lt;ObjectInterface&gt;(someArrayOfObjects);
  </code></pre>
  
  <p>and here is <code>createModel</code> method:</p>
  
  <pre><code>private createModel&lt;T&gt;(someArray: T[]): SomeInterface {
      const model: SomeInterface = (...someCode...);
  
      someArray.forEach((obj: T) =&gt; { model.doSomething(obj.someKey) });
  
      return model;
  }
  </code></pre>
  
  <p>and TypeScript throws me an error: <code>error TS2339: Property 'someKey' does not exist on type 'T'.
  </code>
  Here is the part which I don't get it. If <code>ObjectInterface</code> has <code>someKey</code> and is passed as generic type to <code>createModel</code> then why <code>obj</code> doesn't 'see' it as it's property?</p>
  
  <p>If there is an answer in google then please give me a hint what keys should I search? ;)</p>