Here is an interface and a class that I am working with:
export interface ISample {
propA: string;
propB: string;
}
export class Sample {
private props = {} as ISample;
public get propA(): string {
return this.props.propA;
}
public set propA(propA: string) {
this.props.propA = propA;
}
public get propB(): string {
return this.props.propB;
}
public set propB(propB: string) {
this.props.propB = propB;
}
}
When initializing the object using the class, I do it like this.
let sample = new Sample();
sample.propA = 'A';
sample.propB = 'B';
However, when I attempt to print the object using console.log(sample)
, the output is:
props: {propsA: "A", propsB: "B"}
propsA: (...)
propsB: (...)
My question is, how can I modify the output so that it only shows
{propsA: "A", propsB: "B"}
when using console.log(sample)
?
Note: The versions I am using are typescript 3.8.3
and Angular 9
.