Skip to content

Commit

Permalink
fix: typings for Repository.extend function (#9396)
Browse files Browse the repository at this point in the history
additionally remove duplicated TreeRepository.extend method
  • Loading branch information
ruscon committed Dec 3, 2022
1 parent d490793 commit f07fb2c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/repository/Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,8 @@ export class Repository<Entity extends ObjectLiteral> {
* Extends repository with provided functions.
*/
extend<CustomRepository>(
custom: CustomRepository &
ThisType<Repository<Entity> & CustomRepository>,
): Repository<Entity> & CustomRepository {
custom: CustomRepository & ThisType<this & CustomRepository>,
): this & CustomRepository {
// return {
// ...this,
// ...custom
Expand Down
18 changes: 0 additions & 18 deletions src/repository/TreeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,24 +408,6 @@ export class TreeRepository<
throw new TypeORMError(`Supported only in tree entities`)
}

/**
* Extends tree repository with provided functions.
*/
extend<CustomRepository>(
custom: CustomRepository &
ThisType<TreeRepository<Entity> & CustomRepository>,
): TreeRepository<Entity> & CustomRepository {
const thisRepo = this.constructor as new (...args: any[]) => typeof this
const { target, manager, queryRunner } = this
const cls = new (class extends thisRepo {})(
target,
manager,
queryRunner,
)
Object.assign(cls, custom)
return cls as any
}

/**
* Moves entity to the children of then given entity.
*
Expand Down

0 comments on commit f07fb2c

Please sign in to comment.