mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fix: typings for Repository.extend function (#9396)
additionally remove duplicated TreeRepository.extend method
This commit is contained in:
parent
d490793c7c
commit
f07fb2c3f2
@ -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
|
||||
|
||||
@ -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.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user