How do I define a type that exposes readonly access to a collection that can be manipulated internally by the type itself?
I'm looking for an approach that has the minimum amount of boilerpate.
UPDATE
Thanks for the answers so far, but this should give a clearer idea of what I'm looking for.
export class Item {
public Prop1: number;
public Prop2: string;
}
export class Container {
public get Items(): ??? {
// Return something that enables the client to access and modify individual items but _not_ change the contents
// of the _items array, ideally without just copying the entire array.
}
private _items: Item[] = [];
}