I am working on an instantiator function that generates an instance of a provided class:
declare type ClassType = { new (): any }; // known as "ParameterlessConstructor"
function createInstance(constructor: ClassType): any {
return new constructor();
}
Is there a way for me to modify the function so that it produces an instance of the specified constructor
, rather than just returning any
? I want to ensure type safety for users of this function.