fix: typings for Repository.extend function (#9396)

additionally remove duplicated TreeRepository.extend method
This commit is contained in:
Coroliov Oleg 2022-12-03 16:14:36 +02:00 committed by GitHub
parent d490793c7c
commit f07fb2c3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 21 deletions

View File

@ -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

View File

@ -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.
*