title: Generic type in typeorm and nestjs
body: <p>I am trying to make a base service that will be extendable. The service takes a generic type which will be the Entity type that typeorm uses, that type must have some props and therefore I want it to extend an interface that has those props:</p>
  
  <pre><code>import { getManager, FindConditions, Repository } from "typeorm";
  import { UserInterface } from "./user.interface";
  
  export abstract class UserService&lt;User extends UserInterface&gt; {
    constructor(
      private readonly User: new () =&gt; User,
      protected readonly userRepository: Repository&lt;User&gt;,
    ) {}
  
    async findAll(): Promise&lt;User[]&gt; {
      return await this.userRepository.find();
    }
  
    abstract async findOnePopulated(where: FindConditions&lt;User&gt;): Promise&lt;User&gt;;
  
    async findOneById(id: number): Promise&lt;User&gt; {
      return await this.findOnePopulated({ id });
    }
  
    async updateUser(userId: number): Promise&lt;User&gt; {
      const em = getManager();
      const user = await this.userRepository.findOne(userId);
  
      await em.update(this.User, userId, user);
      return user;
    }
  }
  </code></pre>
  
  <p>I get a type error on this call <code>findOnePopulated({ id })</code> </p>
  
  <pre><code>[ts] Argument of type '{ id: number; }' is not assignable to parameter of type
  'FindConditions&lt;User&gt;'. [2345]
  </code></pre>
  
  <p>and this <code>em.update(this.User, userId, user)</code> is also showing a type error: </p>
  
  <pre><code>[ts]
  Argument of type 'User' is not assignable to parameter of type 'QueryDeepPartialEntity&lt;User&gt;'.
    Type 'UserInterface' is not assignable to type 'QueryDeepPartialEntity&lt;User&gt;'. [2345]
  </code></pre>
  
  <p>It seems to not show any errors if I switch all <code>User</code> to <code>UserInterface</code> instead, is it something wrong with using the syntax <code>&lt;User extends UserInterface&gt;</code>?</p>
  
  <p>I just want to make sure that the generic User type at least has the props in UserInterface.</p>
  
  <p>Here is my UserInterface:</p>
  
  <pre><code>import { BaseEntity } from "typeorm";
  
  export interface UserInterface extends BaseEntity {
    id: number;
  }
  </code></pre>