interface PersonConstructor {
new (name: string, age: number): {
name: string;
age: number;
};
}
class Person {
name: string;
age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
}
function createPerson(ctor: PersonConstructor, name: string, age: number) {
return new ctor(name, age);
}
createPerson(Person, 'zero', 28);