This seems to work…
function getList(): ReadonlyArray<number> {
return [1, 2, 3];
}
const list = getList();
list[0] = 3; // Index signature in type 'ReadonlyArray<number>' only permits reading.
Try it in the Playground
ReadonlyArray<T> is implemented like this:
interface ReadonlyArray<T> {
readonly [n: number]: T;
// Rest of the interface removed for brevity.
}