Let's say I want to build a proxy class from this question's accepted answer.
So I need to prepare some object which contains all the classes as values:
class Class1 {}
class Class2 {}
const ClassEnumeration = {
class1: Class1,
class2: Class2
}
// then it will be used like that
class DynamicClass {
constructor (className, opts) {
return new classes[className](opts);
}
}
new DynamicClass('Class1');
new DynamicClass('Class2');
I can't get which type ClassEnumeration
has in this case. I guess it will be something like Record<string, ...?? >
Which type has the second argument here?