I am currently learning Angular and TypeScript, and I came across a task where I need to create an object or something similar that allows me to define a readable but not editable attribute.
In Java, I would have achieved this by doing the following:
public class Dto {
private long id;
private String desc;
public Dto(String desc){
this.desc = desc;
id= Generator.getRandomId();
}
//Getter for both
// Setter for desc
}
Is there a way to achieve something similar in TypeScript? Someone suggested using an Interface, but I am finding it quite challenging at the moment. Any help is appreciated. Thanks!