I'm confused with typescript class, the private member doesn't work as it should.
class TClass {
public pu = 1;
private pv = 2
constructor(private ar = 1) {
}
}
const f1 = new TClass();
console.log({ ...f1 })
the output of this is
[LOG]: {
"ar": 1,
"pu": 1,
"pv": 2
}
as you can see all the private members are exposed!
but if I want to write a custom class I could use something like this
const JClass= function(ar=1){
const pv=2;
this.pu=1;
};
const f2= new JClass();
console.log({...f2})
and the output will be
[LOG]: {
"pu": 1
}
if you want to play here is a playground
so my question is how to make the typescript really respect the meaning of private?