Coming from a background in C#, I am used to designing most of my classes to be immutable. I am curious about whether it is considered good practice in TypeScript to use private constructor variables and public getters for accessing data within classes.
Take this example:
class UnitType {
constructor(private code: string, private name: string, private unitType: string) {
}
get Code(): string {
return this.code;
}
get Name(): string {
return this.name;
}
get UnitType(): string
return this.unitType;
}
I have not been able to find many examples of TypeScript code structured like the one above. Is there something that I am overlooking?