# TS2542: Index signature in type '…' only permits reading.

> An element of a readonly array or a readonly index signature is assigned to. Copy the data to a mutable value first, or remove readonly.

## What it means

Index signatures marked `readonly`, `ReadonlyArray<T>` and `readonly T[]` only allow reading
elements. Writing through `x[i] = ...` is reported.

## Example

```ts
const names: readonly string[] = ["a", "b"];
names[0] = "c";
```

## How to fix

- Make a copy and change that: `const copy = [...names]; copy[0] = "c"`.
- Use `names.with(0, "c")` (ES2023) to get a changed copy.
- Drop `readonly` if the array is meant to be changed.

Source: https://ts-r.dev/errors/TS2542/
