# Type Inference — TypeScript Fundamentals

Source: https://www.skillbyai.com/en/typescript/ts-type-inference

> Let TypeScript infer types for local variables and learn where explicit annotations are still worth writing.

## TS infers for you

No annotation needed — the initial value tells TS the type, and it's remembered from then on.

```typescript
let count = 5;          // inferred as number
count = "five";
// Error: Type 'string' is not assignable to type 'number'.
```

## When to still annotate

Let inference handle local variables. Annotate function parameters, return types on public APIs, and empty arrays/objects — inference has nothing to go on there.
