Say I have a class A with a hundred properties:
class A {
FOO = "foo";
BAR = "bar";
// (...) 98 more properties
}
In typescript, how does one go about dynamically defining a class B with one getter for each property of class A?
The corresponding statically defined class B would look like this:
class B {
get FOO() {
someFunction('FOO');
}
get BAR() {
someFunction('BAR');
}
// (...) 98 more getters
}
The relation between these classes is as follows:
- a getter name in B is equal to property name in A
- the body of getter in B is exactly the call of function
someFunctionwith a single argument that is a string with the name of the getter