Skip to content

Commit 801ad1d

Browse files
committed
chore: improve TS clone logic
1 parent e90d9b0 commit 801ad1d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/entity/in_memory.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ export class InMemoryEntity {
8989
/**
9090
* @summary Clone this entity
9191
*/
92-
clone<T extends InMemoryEntity>(extraContext?: object): T {
93-
// @ts-ignore
94-
const object: T = new this.constructor({
92+
clone(extraContext?: object): this {
93+
type ThisType = typeof this;
94+
type TConstructor = { new (o: object): ThisType };
95+
96+
const object = new (this.constructor as TConstructor)({
9597
...this.toJSON(),
9698
...extraContext,
9799
});

0 commit comments

Comments
 (0)