Skip to content

Commit

Permalink
Use new when creating a dynamic instance
Browse files Browse the repository at this point in the history
  • Loading branch information
alansemenov committed Oct 9, 2023
1 parent 0983eb8 commit 1e8b4be
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/main/resources/assets/admin/common/js/Class.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export class Class {
private readonly name: string;
private readonly fn: new (...args: any[]) => any;

private name: string;

private fn: Function;

constructor(name: string, fn: Function) {
constructor(name: string, fn: new (...args: any[]) => any) {
this.name = name;
this.fn = fn;
}
Expand All @@ -14,9 +12,6 @@ export class Class {
}

newInstance(constructorParams?: any): any {

let newInstance = Object.create(this.fn.prototype);
newInstance.constructor.call(newInstance, constructorParams);
return newInstance;
return new this.fn(constructorParams);
}
}

0 comments on commit 1e8b4be

Please sign in to comment.