Is there a way to have a private setter for a property in TypeScript?
class Test
{
private _prop: string;
public get prop() : string
{
re
I also hope we could have public getter and private setter. Until we do, another way to handle this is to add additional private getter and setter:
class Test {
_prop: string;
public get prop(): string {
return this._prop;
}
private get internalProp(): string {
return this.prop;
}
private set internalProp(value: string) {
this._prop = value;
}
private addToProp(valueToAdd: string): void {
this.internalProp += valueToAdd;
}
}