When using typescript
, I am passing an entire class as a reference MyClass
to a function. How can I create a new instance of that class within the function?
export class MyClass {
}
createClass(MyClass);
function createClass(classReference) {
const classInstance = new classReference();//this method is not working
}
This functionality is required because in Angular's ModuleWithProviders
, it is not possible to invoke new MyClass()
.