title: How to create fake object from a data type in Typescript for testing
body: <p>I'm looking for a way to simplify making fake data for unit testing in Angular solution.
  I am using interfaces like:</p>
  <pre><code>export interface ReferenceDataItemCommon {
    codeDescription?: string;
    code: string;
    deleted?: boolean;
  }
  </code></pre>
  <p>As data types in application. Currently using Factory.ts + Faker to create fake objects for purpose of tests:</p>
  <pre><code>  export const fakeReferenceDataItemCommon = Factory.Sync.makeFactory&lt;ReferenceDataItemCommon&gt;({
      code: Factory.each(() =&gt; Faker.lorem.word()),
      codeDescription: Factory.each(() =&gt; Faker.lorem.sentence(4)),
    });
  </code></pre>
  <p>But I'm curious if there is a way to simplify it even more for when you just want a object for your test and speed up creating it even more.
  Is it possible in Typescript to have a generic method that would return a object of that datatype?</p>
  <pre><code>  const fake = createFake&lt;ReferenceDataItemCommon&gt;();
  </code></pre>
  <p>What my initial idea was is to do something like:</p>
  <pre><code>Object.keys(object).forEach(key =&gt; {
    switch(typeof object[key]) {
      case 'string':
         object[key] = Faker.lorem.word();
         break;
    }
  }
  return object;
  </code></pre>
  <p>And for complex object call this method recursively. Is that possible, and if what would be a better approach to do this as I feel a bit out of my depth?</p>