title: Cannot read property 'create' of undefined in TS
body: <p>I create an function to create new user in NestJS/TypeScript,</p>
  
  <p>after launch my function, my console throw me this:</p>
  
  <pre><code>TypeError: Cannot read property 'create' of undefined
      at Repository.create (/mnt/c/Users/Maciek/Desktop/personal-data/node_modules/typeorm/repository/Repository.js:49:29)
      at UserService.create (/mnt/c/Users/Maciek/Desktop/personal-data/dist/user/user.service.js:60:40)
      at AuthController.register (/mnt/c/Users/Maciek/Desktop/personal-data/dist/auth/auth.controller.js:38:45)
  </code></pre>
  
  <p>can someone tell what i have doing wrong?</p>
  
  <p>rest of my code:</p>
  
  <pre><code>export class CrudService&lt;T extends ExtendedEntity&gt;{
      protected repository: Repository&lt;T&gt;;
  
      constructor(
          repository?: Repository&lt;T&gt;
      ){
          if(repository){
              this.repository = repository;
          }
      }
  
      public async create(data: DeepPartial&lt;T&gt;): Promise&lt;T&gt; {
          const entity: T = this.repository.create(data);
  
          await this.validate(entity, {
              groups: ['create']
          });
          return entity.save();
      }
  }
  </code></pre>
  
  <pre><code>import { CrudService } from 'src/helpers/service/crud-service';
  
  @Injectable()
  export class UserService extends CrudService&lt;UserEntity&gt;{
      private logger = new Logger(UserService.name);
      constructor(
          protected readonly repository: Repository&lt;UserEntity&gt;,
      ) {
          super();
      }
  
      public async create(data: DeepPartial&lt;UserEntity&gt;): Promise&lt;UserEntity&gt; {
          const entity = this.repository.create(data);
          await this.validate(entity);
          entity.hashPassword();
          if(!entity.createdAt){
              entity.createdAt = new Date;
          }
          const user = await entity.save();
          return user;
      }
  }
  </code></pre>
  
  <pre><code>@Controller('api/auth')
  @ApiTags('auth')
  export class AuthController {
      private logger = new Logger(AuthController.name);
  
      constructor(
          private readonly userService: UserService
      ){}
  
  
  
      @Post('register')
      @ApiBody({ required: true, type: UserEntityDto })
      @ApiResponse({ status: 204, description: 'NO_CONTENT'})
      public async register(@Body() data: DeepPartial&lt;UserEntity&gt;): Promise&lt;void&gt; {
          const user = await this.userService.create(data);
          this.logger.debug(`[register] User ${data.email} register`);
      }
  }
  </code></pre>