# TS2540: Cannot assign to '…' because it is a read-only property.

> A readonly property or a const enum member is assigned to. Create a new object instead, or remove readonly if the property should change.

## What it means

Properties declared `readonly`, getters without setters, `as const` objects and the properties of
`Readonly<T>` can't be assigned after the object is created.

## Example

```ts
interface Config {
  readonly port: number;
}
const config: Config = { port: 80 };
config.port = 8080;
```

## How to fix

- Build a new object: `const next = { ...config, port: 8080 }`.
- Remove `readonly` if the property is meant to change.

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