title: Use Classes as both variable and type in typescript
body: <p>I was wondering if something like this is possible.</p>
  <p>I am using a NestJS and TypeORM for my project, and want to use transactions. I am trying to replace this usage:</p>
  <pre><code>getConnection().transaction(async (transactionManager) =&gt; {
      const repositoryOne = transactionManager.getCustomRepository(RepostiroyOne) // obviusly types are inherited here
      const repositoryTwo = transactionManager.getCustomRepository(RepostiroyTwo)
  
     // code in transaction
  })
  
  </code></pre>
  <p>with something like this:</p>
  <pre><code>const transaction = async(callback, repositories) =&gt; {
      const getTransactionRepositories = (manager: EntityManager) =&gt; {
          return repositories.map((repository) =&gt; manager.getCustomRepository(repository));
      };
      return getManager().transaction(async (transactionManager) =&gt;
          callback(...getTransactionRepositories(transactionManager)),
      );
  };
  </code></pre>
  <p>then in the code to use it:</p>
  <pre><code>transaction(async (repoOne, repoTwo) =&gt; {
     // code to run inside transaction
     // but types here are not inherited
     // if i say repoOne: RepositoryOne it is working fine, but I tried to minimize repetition and
     // would like if repoOne is a type of RepositoryOne without manually adding it
  }, [RepositoryOne, RepositoryTwo])
  </code></pre>
  <p>So as I mentioned in the first example what I am trying to exclude:</p>
  <p><code>const repositoryOne = transactionManager.getCustomRepository(RepositoryOne)</code></p>
  <p>then this repostiryOne becomes:</p>
  <p><code>repositoryOne: RepositoryOne</code></p>
  <p>So in my function, 1st param, e.g. <code>repoOne</code> would have a type of <code>RepositoryOne</code> provided as a first item in the array and so on.</p>
  <p><strong>note</strong>: Talking strictly about TypeORM tranasaction decorators, I won't use them since there are some issues with nest testing module and typeorm decorators.</p>
  <p>Any help is appreciated</p>