I have a typescript class that has the following properties:
export class apiAccount {
private _balance : apiMoney;
get balance():apiMoney {
return this._balance;
}
set balance(value : apiMoney) {
this._balance = value;
}
private _currency : string;
get currency():string {
return this._currency;
}
set currency(value : string) {
this._currency = value;
}
...
I need to create an empty instance of this class:
let newObj = new apiAccount();
And then check if it has a setter for the "currency", for example. I thought this was exactly what it was doing getOwnPropertyDescriptor, however, apparently, I was wrong:
Object.getOwnPropertyDescriptor(newObj, 'currency')
Object.getOwnPropertyDescriptor(newObj, '_currency')
Both return undefined. But chrome seems to do it! When I hover over an instance, it shows me the properties and shows them as undefined. How can I get a list of these property names or check if a property descriptor exists in the object?

David source
share