# TS2454: Variable '…' is used before being assigned.

> A variable is read on a path where it may not have been assigned yet. Initialise it where it is declared, or assign it on every path.

## What it means

With `strictNullChecks`, the checker tracks whether a `let` variable without an initialiser has
been assigned on every path before it is read. Reading it where some path skips the assignment
is reported, because the value there is `undefined`.

## Example

```ts
declare const ok: boolean;
let message: string;
if (ok) {
  message = "done";
}
console.log(message);
```

## How to fix

- Give the variable an initial value: `let message = ""`.
- Assign it in every branch (add the `else`).
- If `undefined` is a valid state, say so in the type: `let message: string | undefined`.

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