In TypeScript, I have a data object with a property defined like this:
get name() {
return this._hiddenName;
}
set name(value) {
...stuff...
this._hiddenName = value;
}
However, when I look at the output code, I notice that the property is on the prototype rather than the object itself. This is not an issue when calling the property, but it becomes problematic when attempting to iterate over the object's properties using Object.keys(), as these properties are not picked up.
This becomes particularly troublesome when passing an object with properties into a FormGroup in Angular. The FormGroup uses Object.keys to map the object to the form, but only finds the backing properties and not the ones I actually want to expose.