i.e. if I have an object Person which looks like
class PersonClass implements Person {
private _name : string;
private _age : number;
get name() : string {return this._name}
get age() : number (return this._age)
constructor(name : string, age : number) {
this._name = name;
this._age = age;
}
}
And I have interface with the public properties:
interface Person {
name : string;
age : string;
}
And what I need to do is get an object representation of the person which reflects the Person interface, and so looks like
{ name: John, age: 23}
Is there a way to do that? I tried casting ( person as Person
} and JSON.stringify and object assign and I seem to end up with object that contains the private data _name
and _age
but not the interface members name
and `age'